|
-
Sep 30th, 2010, 02:04 AM
#1
Thread Starter
PowerPoster
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
-
Sep 30th, 2010, 07:24 AM
#2
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.
-
Oct 1st, 2010, 03:48 AM
#3
Thread Starter
PowerPoster
Re: insert value in access table based a string
 Originally Posted by RhinoBull
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?
-
Oct 1st, 2010, 07:13 AM
#4
Re: insert value in access table based a string
I don't quite understand what you are trying to say... Sorry.
-
Oct 1st, 2010, 09:25 AM
#5
Thread Starter
PowerPoster
Re: insert value in access table based a string
 Originally Posted by RhinoBull
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|