Search code examples
vbams-accessmismatchsubform

error type mismatch error message


I'm working on an application in Access and it's been almost a week looking at the same line of code again, and again and I can't find the error(the error is a type mismatch in the AT = definition line) what I want is to filter a subform datasheet by a combobox presenting date values, the sub is as this:

    Private Sub cbSelectDate_AfterUpdate()

    Dim AT As Date

    If Me.cbSelectDate = "" Then
    MsgBox ("First you need to fill the employee field")
    End If

    'On Error Resume Next

     AT = "select * from subform where ([AppointDate] = #" & Me.cbSelectDate & "#)"

     Me.subform.Form.RecordSource = AT

     Me.subform.Form.Requery
     End Sub

Solution

  • You are passing a string into a date, change it to String