Reputation:
I am currently working on a Database with MS Access.
The Problem: I have a Main Form with a ComboBox (TNIDCombo) and a Subform. The subform contains a Table to be filtered, the ComboBox contains Values that are supposed to be used for filtering the subform.
Surfing Stackoverflow I learned, that you can bind macros on different states of a ComboBox, like "afterUpdate", and that is what I tried:
Private Sub TNIDCombo_AfterUpdate()
On Error GoTo Proc_Error
If IsNull(Me.TNIDCombo) Then
Me.DQ_ListeTNIDs.Form.Filter = ""
Me.DQ_ListeTNIDs.Form.FilterOn = False
Else
Me.DQ_ListeTNIDs.Form.Filter = "WMSTI_AUFTRNRAG=" & Me.TNIDCombo
Me.DQ_ListeTNIDs.Form.FilterOn = True
End If
Proc_Exit:
Exit Sub
Proc_Error:
MsgBox "Fehler " & Err.Number & " Beim Setzen des Filters:" & vbCrLf & Err.Description
Resume Proc_Exit
End Sub
DQ_ListeTNIDs
is the name of the Subform and "WMSTI_AUFTRNRAG"
is the name of the columnheader of one of the columns in the subform that is supposed to be filtered.
Sadly, This throws the error 3464, type mismatch, when using the ComboBox in FormView Can someone point the reason for that error out to me?
Thank you for any answers. -Ninsa
Upvotes: 0
Views: 83
Reputation:
As @Gustav said:
Me.DQ_ListeTNIDs.Form.Filter = "WMSTI_AUFTRNRAG='" & Me.TNIDCombo & "'"
Did the trick. The Colum only contains numeric values, but the data type of the field is short text.. TIL.
Thank yu Gustav
Upvotes: 1