0
votes

I've been busy creating a database and I am using combo boxes to filter several lists of data. I used the following code:

Private Sub cbobedrijf_AfterUpdate()
Me.Filter = "Bedrijf_klant = '" & Me.cbobedrijf & "'"
Me.FilterOn = True
End Sub

Which worked perfectly for about four forms and 10 combo boxes in total. When I tried to use this code on my last form I received the following error:

Data type mismatch in criteria expression

I am not able to solve this problem and I do not understand why this error appears, because I copied->pasted the code and changed it into:

Private Sub cbobedrijf_AfterUpdate() 
Me.Filter = "bedrijf_project = '"& Me.cbobedrijf & "'" 
Me.FilterOn = True 
End Sub

The same I did for all the other combo boxes.

1
What is Me.cbobedrijf ? try doing cstr(Me.cbobedrijf) or int(Me.cbobedrijf) depending on what it's supposed to be - jae555
Thank you for your response, Me.cbobedrijf is the combo box which I want to use to filter the collum of bedrijf_project. I tried doing cstr(Me.cobobedrijf) and (Me.cbobedrijf), but I ended up with the same error. - fleur

1 Answers

0
votes
Private Sub cbobedrijf_AfterUpdate() 
    Debug.Print Me.FilterOn, "bedrijf_project = '" & Me.cbobedrijf & "'" 
    Me.Filter = "bedrijf_project = '"& Me.cbobedrijf & "'" 
    Me.FilterOn = True 
End Sub