Apr 5, 2005 #1 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.
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.
Apr 5, 2005 #2 earthandfire Programmer Mar 14, 2005 2,924 GB 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 Upvote 0 Downvote
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
Apr 6, 2005 Thread starter #3 PNC MIS Jun 7, 2001 87 US 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. Upvote 0 Downvote
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.