form name dim

  • Thread starter Thread starter David
  • Start date Start date
D

David

This is an example of what I am trying to do

Sub Client_LostFocus()
Dim formname As Variant
formname = Fuel_Ticket
MsgBox Forms(the).Controls("Client")

End Sub

I cannot seem to figure out what should go in the place of Variant here.
It doesn't work if formname is a string. What should it be?

Thanks
David
 
Thank you for being prompt, though, Im afraid my question still stands.
this code:

Sub Client_LostFocus()
Dim formname As String
formname = "Fuel_Ticket"
MsgBox Forms(formname).Controls("Client")

End Sub

did not work
however when I changed it to:

Sub Client_LostFocus()
Dim formname As Variant
formname = Fuel_Ticket
MsgBox Forms(formname).Controls("Client")

End Sub

it worked. Indicating (i think) that it is not a string that it needs but
something else.
Please ignore that it seems to be using it inside the form and I could just
say Me.Client, i am just using that as an example

thanks
David
 
Back
Top