Results 1 to 5 of 5

Thread: insert value in access table based a string

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,939

    insert value in access table based a string

    I use the tipical

    While Not RS.EOF

    rs(0)
    rs(1)
    move.next

    ....
    wend

    and have an acces table with field name CODE1, CODE2, CODE7, CODE9....

    During the while not loop the value in rs(0) can assume CODE1, OR CODE2 ....
    and rs(1) can assume value 1 or 14

    How to insert the related avlue of rs(1) into the table where the filed name is the value of rs(0)...

    in thi case the final table is:
    CODE1 CODE2
    1 14

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: insert value in access table based a string

    Execute sql statement via ado command or connection object:
    Code:
    Dim strSQL As String
    
    strSQL= "Update MyTable Set Code2 = " & RS.Fields(1).Value & " Where Code1 = " & RS.Fields(0).Value
    
    adoConnection.Execute strSQL
    ... or something similar to that.

    Also, check out ADO Tutorials - there is plenty of useful info.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,939

    Re: insert value in access table based a string

    Quote Originally Posted by RhinoBull View Post
    Execute sql statement via ado command or connection object:
    Code:
    Dim strSQL As String
    
    strSQL= "Update MyTable Set Code2 = " & RS.Fields(1).Value & " Where Code1 = " & RS.Fields(0).Value
    
    adoConnection.Execute strSQL
    ... or something similar to that.

    Also, check out ADO Tutorials - there is plenty of useful info.

    Yes tk RhinoBull ...

    but my into the loop i cannot have a fixed string value, but dinaimic a time a can have CODE1, CODE2, CODE7, CODE9... a time i can have CODE11, CODE32, CODE07...

    I think i need an array, or not?

  4. #4

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,939

    Re: insert value in access table based a string

    Quote Originally Posted by RhinoBull View Post
    I don't quite understand what you are trying to say... Sorry.
    in effect during the loop i can have a seriries of value:


    Code2 = " & RS.Fields(1).Value
    Code6 = " & RS.Fields(1).Value
    Code9 = " & RS.Fields(1).Value
    ...
    Code11 = " & RS.Fields(1).Value
    Code18 = " & RS.Fields(1).Value

    or

    Code35 = " & RS.Fields(1).Value
    Code64 = " & RS.Fields(1).Value
    Code29 = " & RS.Fields(1).Value

    in this case i loop only if Code have a rs.fileds(1) filled from the select query...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width