I have a textbox on a form (form2) where I need to set the display with vba as it may change depending on the data selected in a combobox on another form (form1).
I'm using the following code in the form (form2) OnLoad event:
When debugging, the correct value shows up for the "contactnumber" variable and the control source of the text box but it is empty.
What am I doing wrong?
I'm using the following code in the form (form2) OnLoad event:
Code:
Dim contactnumber As Long
contactnumber = [Forms]![Form1]![subfrm].[Form]![Contact]
If Forms!frmForm1.cmbobox= "Selection1" Then
Me.Textbox1.ControlSource = DLookup("[LastName] & "", "" & [Title] & "" "" & [FirstName]", "[table1]", "[ID] = " & contactnumber)
End If
Me.Textbox1.Requery
When debugging, the correct value shows up for the "contactnumber" variable and the control source of the text box but it is empty.
What am I doing wrong?