Hey,
I have a form where I would like to read the value from another table, depending on the choice from a combobox and put it in a textbox on the current form. Basically, when the user selects a chassis from cboChassis (the values of this combobox are read from the field "System Name" in a table called "Systems"), I would like access to read the url (it is the drive location of a picture, in a text field) from the "Picture" field in the table "Systems" and put it in the textbox "txtPicHyperlink" on the current form.
I receive the error: Run-time error '3075': Syntax error (missing operator) in query expression 'System Name = 'Full Antec System''. On the bolded line.
"Full Antec System" was the value in the combobox so I know that part of the code is working correctly, but I cannot see what is wrong with my query expression!
Here is the code:
Code:
Private Sub cboChassis_Change()
Dim db As DAO.Database
Set db = CurrentDb
Dim strWhere As String
Dim url As String
'On Error Resume Next
'strWhere = "System Name = " & Chr(39) & Me.cboChassis.Value & Chr(39) 'Trying different ways of reading the value from the form
strWhere = "System Name = " & Chr(39) & Forms![LabRequestForm]!Chassis & Chr(39)
url = DLookup("Picture", "Systems", strWhere)
txtPicHyperlink.Value = url
'txtPicHyperlink.Value = strWhere 'for viewing strWhere - I would comment out the 2 lines above this and uncomment this one to view it
End Sub
When I put strWhere in the textbox instead of url and comment out the DLookup line and the one below it, I see the query is System Name = 'Full Antec System'. This looks correct to me, so I am not sure what is wrong! Please let me know if any clarification is needed.
Any help is greatly appreciated!
Thanks in advance,
Healey33