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!

Referencing field via a given string value

Status
Not open for further replies.

DAmoss

Technical User
Jul 23, 2003
169
GB
Hi

Can anyone tell how to convert / use the value stored in a string field for directly referencing another given field value?

I have a grid of textboxes (A1, A2 ... M1 etc) and I want to be able to put an 'X' in the chosen field which is passed via string value (ie. B3)

My other thought is that maybe I should loop through all the fields until I find the one with the same label name?


Here's what I've been playing with:

Private Sub UpdateGrid(strField As String)
Dim frm As Form

With frm
.Fields(strField).Value = "X"
End With

End Sub

Private Sub Form_Current()
UpdateGrid ("B3")
End Sub


Thanks for you help in advance
DAmoss
 
Replace this:
.Fields(strField).Value = "X"
with this:
.Controls(strField).Value = "X"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for the big hint, it worked using the following code:

Private Sub UpdateGrid(strField As String)
Forms!sbfrmMapXY.Controls(strField).Value = "X"
End Sub

Private Sub Form_Current()
UpdateGrid ("B3")
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top