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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Indirect reference to a field?

Status
Not open for further replies.

MarkRobinson

Programmer
Feb 18, 2000
112
US
I want to fill all fields in a do loop, which requires that the rs1.<fieldname> be a variable
The code below doesn't work. I need "rs1.fname" to be "rs1.<contents of fname>."

Set db = CurrentDb
q1 = "SELECT FName, address, phone from msg1;"
Set rs1 = db.openrecordset(q1)

mcount=1
rs1.addnew
do while mcount<4
fname =rs1(mcount).Name 'Fname on the first pass, etc
rs1.fname="Text for Fname" 'DOESNT WORK
mcount=mcount+1
loop
Rs1.Update
 
rs1(fname) = "Text for Fname"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top