Me.Filter runtime error 3464 and 3075

nick1408

Registered User.
Local time
Tomorrow, 08:47
Joined
Jun 16, 2016
Messages
77
I'm using the following code to try and get an unbound combo to filter a split form:

Code:
Private Sub filterCombo_AfterUpdate()
Me.FilterOn = False
Dim strFilter As String
strFilter = Me.filterCombo.Value
Debug.Print Me.filterCombo
Debug.Print Me.FilterOn, "[Course Name] = " & strFilter & ""
Me.Filter = "[Course Name] = " & strFilter & ""
'DoCmd.ApplyFilter , "[Course Name]='strFilter'"

Me.FilterOn = True

End Sub

The immediate window shows the following:
Code:
Year - SUPPLIER - Course Name
False[Course Name] = Year - SUPPLIER - Course Name

This gives me a runtime error 3075.

If I change the code to this:
Code:
Debug.Print Me.filterCombo
Debug.Print Me.FilterOn, "[Course Name] = '" & strFilter & "'"
Me.Filter = "[Course Name] = '" & strFilter & "'"
The immediate window shows this:
Code:
Year - SUPPLIER - Course Name
True[Course Name] = 'Year - SUPPLIER - Course Name'

This gives a runtime error of 3464.

If I manually copy and paste the contents into the column's "Text Filters Equals..." the filter works fine. I have also attempted DoCmd.ApplyFilter but to no success. Even if I could get a macro to copy filterCombo.value and paste it in [Course Name] "Text Filters Equals..." I would be happy.

Any help is appreciated.
 
Error 3464 or "Data type mismatch in criteria expression" implies [Course Name] is something other than a string. I suggest checking type of the field [Course Name].
 

Users who are viewing this thread

Back
Top Bottom