Data mismatch - on report opening

Egg 'n' Bacon
5StarLounger
Posts: 736
Joined: 18 Mar 2010, 11:05

Data mismatch - on report opening

Post by Egg 'n' Bacon »

Hi again :)

I'm hoping to open a report (from a form that shows single records) showing only the current record.

I can open the report with all records, but when I add the WhereCondition I get "Data type mismatch in criteria expresssion" error :scratch:

The line of code =

Code: Select all

DoCmd.OpenReport reportname:="lblRecord", View:=acViewPreview, WhereCondition:="ID=" & Chr(34) & Me.ID & Chr(34)

User avatar
HansV
Administrator
Posts: 78512
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Data mismatch - on report opening

Post by HansV »

What is the data type of the ID field? If if is a number (for example an AutoNumber field), use

DoCmd.OpenReport ReportName:="lblRecord", View:=acViewPreview, WhereCondition:="ID=" & Me.ID

The quotes Chr(34) are only needed for text fields.
Best wishes,
Hans

Egg 'n' Bacon
5StarLounger
Posts: 736
Joined: 18 Mar 2010, 11:05

Re: Data mismatch - on report opening

Post by Egg 'n' Bacon »

Thank you kind sir, that was exactly what it was.