DATA TYPE MISMATCH IN CRITERIA EXPRESSION - Chr(34)

S

Sammie

I used a string to filter a report successfully when my criteria was
contained in a text field. Now I want to do the same with a number field,
and I am getting the data type mismatch in criteria expression error. Is
there a different chr number that I should use when [REFNO] is a long integer?

Dim stDocName As String
strCriteria = "[REFNO] = " & Chr(34) & Me!RefNo & Chr(34)
DoCmd.OpenReport "RfqReport", acPreview, , strCriteria

Thanks
Sammie
 
A

Allen Browne

Drop the quotes:
strCriteria = "[REFNO] = " & Me!RefNo

That will error if RefNo is null, so you either want use IsNull() to avoid
the whole thing, or use Nz() like this:
strCriteria = "[REFNO] = " & Nz(Me!RefNo, 0)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top