Is this possible???

pas123

Registered User.
Local time
Today, 09:01
Joined
Mar 10, 2003
Messages
40
Hi,

I want to create a variable that will = the name of a control then use that variable to get the value of the control.
something like this:
On the form I have a text box [919000Name] 'Actually many different named text boxes[919100Name],[919110Name]...
In the onclick of a button:
For Each ctl In pge.Controls
If Not ctl.Value = "" Then
title = "Me![" & ctl.value & "Name]" ' Where ctl.value = 919000
Me![PlDwgTitle] = (Me![ProjectName] & " " & title) ' Which would make Me![PlDwgTitle].value = Me![919000Name].value
End If
Next ctl

My real question is how to make the "title" variable be the same as typing Me![919000Name]?
Hope this all makes sense.

Thanks
paul
 
Not sure I understand what you're asking, but instead of:
title = "Me![" & ctl.value & "Name]" (where ctl.value = 919000)
you want the expression to read by Access to be:
title=Me![919000]

You can use:
title=ctl.Name
 
That would work if I only wanted the value of [919000] but that's not it.

I have several option buttons and for each one that is selected a predefined value is assigned to a text box [H919000], [H919111] and so on. for each of the option buttons I have a text box [919000Name], [919111Name] and so on. What I need is to get the value of corsponding "Name" textbox for each of the predefined textboxes. Using the for each statement I am able to get part of the textbox name(919000),(919111) thru the ctl.value. Now I need to combine the ctl.value and "Name" then use that to get the value of the textbox by that name and assign it to a textbox.
Me![PlDwgTitle] = (Me![ProjectName] & " " & title)
Where title = Me![ & the value of ctl.value & Name]
Hope this helps
paul
 

Users who are viewing this thread

Back
Top Bottom