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

Using a concatenated string as field 1

Status
Not open for further replies.

tbellomo

Technical User
Jan 28, 2002
73
US
Hello...
Sorry if the subject line is confusing. What I'm doing involved concatenating a string and variable to make a field name, then storing that in a variable, then using that variable to assign a value to a recordset... that probably doesn't make sense, so I'll paste the code...

Do
val = "Me.Text" & cntr2
rs(cntr) = val.Value
cntr = cntr + 1
cntr2 = cntr2 + 1
Loop Until cntr = rs.Fields.Count + 1


if you can think of the correct way to let the computer know what I want it to do, please share. If you need clarification, let me know.

Thanks a million,
Tim
 
o.k. i'm a little confused. so a person types in "Dog" into the texbox. you want to put dog1, dog2, dog3, etc into the the table until all fields are populated?
I'd be glad to help if i can, bu i am not sure what you are trying to do.
 
You need to to get a reference to the actual control to retrieve the value before using it that way:


Dim vCtrl As Variant
Dim strCtrl As StringDo
strCtrl = "Me.Text" & cntr2
Set vCtrl = Me.Controls(strV)
rs(cntr) = vCtrl.Value
cntr = cntr + 1
cntr2 = cntr2 + 1
Loop Until cntr = rs.Fields.Count + 1







Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top