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

Loop thru text boxes with different names 1

Status
Not open for further replies.

xuanb

Programmer
Apr 9, 2003
29
US
I have many rows of text box pairs that need to display the result of a function call. There's more to it but the bottomline is I want to loop thru a collection and concatenate the text box names accordingly and display the result in the text box. I am stuck because sofar "Me.txtRprGrounds" is a String but how do I make Access understand it's a text box. Does anyone know the solution??

Dim txtRPR, txtMTN As String 'Or some other data type??
Dim coll As New Collection, var As Variant

coll.Add "Grounds"
coll.Add "Parking"

For Each var in coll
txtRPR = "Me.txtRpr" & var
txtMTN = "Me.txtMtn" & var

txtRPR = Cost(r)
txtMTN = Cost(m)
Next
 
Hi!

I can tell you how to use a string to identify a control. If there turns out to be other issues let us know.

Dim txtRPR, txtMTN As String 'Or some other data type??
Dim coll As New Collection, var As Variant

coll.Add "Grounds"
coll.Add "Parking"

For Each var in coll
txtRPR = "txtRpr" & var
txtMTN = "txtMtn" & var

Me.Controls(txtRPR).Value = Cost(r)
Me.Controls(txtMTN).Value = Cost(m)
Next

hth


Jeff Bridgham
bridgham@purdue.edu
 
Lightning and thunder!!! :) :) :) Exactly what I needed. And so quick, too. Thank you so much, Jeff!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top