I am an excel user who is very new to Access. I am trying to change the data displayed in a form's subform, based on the data chosen in the form's combo box.
I have two tables
Table 1 = Member table with a full listing of all my members each record in the table has the following fields: last name, first name, member status)
Table 2 = Table with a list of unique last names from Member table. This table only has the last name field
I create a form - in the detail part of the form, I inserted a subform which displays all data from the Member table. In the header of the form I inserted a combo box. The values available to the combo box are from my table listing only unique last names.
I want to be able to choose a Last name (or type a last name) into the combo box. This will cause the data for only the members in the Member table that have that last name to be displayed in the subform. Essentially filtering what is shown in the subform based on what is selected or typed into the combo box. So if I type or select Smith in the combo box - All of my members with the last name Smith would display in the subform.
I have tried to do this by using After Update in the Event tabs in the Property Sheet for the combo box
Private Sub cbo_Lastname_Search_AfterUpdate()
Dim myMember As String
myMember = "Select * from tblMembers where ([Last_Name] = " & Me.cbo_Lastname_Search & ") "
Me.tblMembers_subform.Form.RecordSource = myMember
Me.tblMembers_subform.Form.Requery
End Sub
When I run this, I get the following error
Run-time error '3464'
Data type mismatch in criteria expression
I don't know how to try to fix this error. Any help is most appreciated.