Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd.OpenReport does not work with ASC in where condition

Status
Not open for further replies.

PNC

MIS
Jun 7, 2001
87
US
Hi,

This is my code
Code:
DoCmd.OpenReport stDocName, acPreview, , "ASC([Field]) like ASC("'Variable'")"

ERROR: Data type mismatch in criteria expression

It works fine in a query, therefore it should also work in the code, right?

Any ideas why not?

Thanks,
PNC.
 
ASC returns the character (ASCII) value ie a number, which you are comparing to a string. eg ASC("A") returns 65 which doesn't equal "65
 
But Field is a string, so is the variable...

Code:
DoCmd.OpenReport stDocName, acPreview, , "ASC([Field]) like ASC("& Variable &")"

Is it because sometimes the [Field] might be null?

Any ideas, anyone???

Thanks,
PNC.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top