Hi all,
I need a form to populate once an option is chosen from a listbox.
What I having working:
User Types into a textbox
The list box filters based on value in the text box
The user chooses item from the list
The text box now matches this
Where I am experiencing problems:
The user clicks on the search button and the form populates with the correct record based on the value in the textbox.
Code I have:
Private Sub cmd_UpdateSearch_Click()
Dim rst As DAO.Recordset
Dim strsql As String
strsql = "Select * from Mastertbl where FName = " & Search.Value & ""
Set rst = CurrentDb.OpenRecordset(strsql)
If rst.EOF Then
MsgBox " Not in database"
FirstName.Value = Nothing
LastName.Value = Nothing
Number.Value = Nothing
Email.Value = Nothing
Address.Value = Nothing
Else
FirstName.Value = rs.field("First Name")
LastName.Value = rs.field("Last Name")
Number.Value = rs.field("Phone Number")
Email.Value =rs.field("Email Address")
Address.Value = rs.field("User Address")
End If
rst.Close
Set rst = Nothing
End Sub
I keep getting a run time error Runtime Error 3075: Syntax Error (missing operator) in query expression '[FName] = Sarah'
When I click debug is shows me this line:
Set rst = CurrentDb.OpenRecordset(strsql)
What is wrong here - please explain in lay man terms if possible.
Thank you in advance.
I need a form to populate once an option is chosen from a listbox.
What I having working:
User Types into a textbox
The list box filters based on value in the text box
The user chooses item from the list
The text box now matches this
Where I am experiencing problems:
The user clicks on the search button and the form populates with the correct record based on the value in the textbox.
Code I have:
Private Sub cmd_UpdateSearch_Click()
Dim rst As DAO.Recordset
Dim strsql As String
strsql = "Select * from Mastertbl where FName = " & Search.Value & ""
Set rst = CurrentDb.OpenRecordset(strsql)
If rst.EOF Then
MsgBox " Not in database"
FirstName.Value = Nothing
LastName.Value = Nothing
Number.Value = Nothing
Email.Value = Nothing
Address.Value = Nothing
Else
FirstName.Value = rs.field("First Name")
LastName.Value = rs.field("Last Name")
Number.Value = rs.field("Phone Number")
Email.Value =rs.field("Email Address")
Address.Value = rs.field("User Address")
End If
rst.Close
Set rst = Nothing
End Sub
I keep getting a run time error Runtime Error 3075: Syntax Error (missing operator) in query expression '[FName] = Sarah'
When I click debug is shows me this line:
Set rst = CurrentDb.OpenRecordset(strsql)
What is wrong here - please explain in lay man terms if possible.
Thank you in advance.