rel0aded0ne
rel0aded0ne

Reputation: 461

Run-time error '3464': Data type mismatch in criteria expression

I want to create a report with date as a criterium.

I have a TextBox (unbound) named ber-datum and i want to select every entry in my table thats matches with the date.

I created a button with the following code behind it.

Private Sub ber_datum_button_Click()
    DoCmd.OpenReport "ber-planung", acViewReport, , "[Datum]='" & Me.[ber-datum] & "'"
End Sub

But im always getting the "Data type mismatch" error. The data type of Datum in my table is set to Date.

Every other report works fine except this one.

Example:

Private Sub ber_hid_button_Click()
    DoCmd.OpenReport "ber-planung", acViewReport, , "[HID]='" & Me.[ber-hid] & "'"
End Sub

Upvotes: 1

Views: 1912

Answers (1)

Gustav
Gustav

Reputation: 55981

Date expressions must be wrappen in octothorpes:

Private Sub ber_datum_button_Click()
    DoCmd.OpenReport "ber-planung", acViewReport, , "[Datum]=#" & Format(Me![ber-datum].Value, "yyyy\/mm\/dd") & "#"
End Sub

Upvotes: 5

Related Questions