Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a variable in a recordset 1

Status
Not open for further replies.

nickperez22

Technical User
Jun 13, 2001
62
US
I want to create a do loop in a recordset where I want to change the field that is being updated from Field01 to Field02, Field03 etc. on each loop.

rst2.Edit
rst2!Field01 = intUpdate
rst2.Update

I've tried a few things like setting a variable to replace the Field01 so that the code would read something like rst2!strNumber but I get an object not found error.

Is it possible to set a variable after the ! bang operator in a recordset, if so what is the proper syntax?
 
Yes, it is (leave out the bang).

'Ordinal position
rs2(0)=intUpdate

'Variable
rs2(varThis)=intUpdate

'String & Variable
rs2("Field" & i)=intUpdate
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top