?
Solved

access open report criteria - error!

Posted on 2012-03-19
9
Medium Priority
?
373 Views
Last Modified: 2012-03-19
I'm trying to open a report with the following statement:

DoCmd.OpenReport "CatWebWork2CommentR", acViewPreview, , "LinkToID = 526 AND CommentTypeID = 'CatWebWork'"

I get an error: "Data type mismatch in criteria expression", and access crashes.

What can be causing this?
0
Comment
Question by:etech0
  • 5
  • 4
9 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 37738035
Is commentTypeID numeric?  You are passing a string literal.  

If CatWebWork is a variable or field on your form, and commenttypeID is numeric, try this syntax:

DoCmd.OpenReport "CatWebWork2CommentR", acViewPreview, , "LinkToID = 526 AND CommentTypeID = " & CatWebWork
0
 
LVL 10

Author Comment

by:etech0
ID: 37738049
It's a lookup field in the table. Am I supposed to pass the number, or the text?
0
 
LVL 61

Expert Comment

by:mbizup
ID: 37738076
Look at the properties for CommentTypeID in the table's design view.

If it is a numeric field, you should pass a number.

If it is a text field, you should pass the text value.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 10

Author Comment

by:etech0
ID: 37738082
It's a number. I'll try passing a number.
0
 
LVL 10

Author Comment

by:etech0
ID: 37738093
Now I don't get the error, but it's not filtering by LinkToID!
0
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 37738109
Then the criteria are probably mutually exclusive - ie: you don't have any records in the recordsource where both of these are found:
          LinkToID = 526
          CommentTypeID  =  the number that you passed
0
 
LVL 10

Author Comment

by:etech0
ID: 37738116
Forget the last comment - it's working now.

Just give me a few minutes to test it out...
0
 
LVL 10

Author Closing Comment

by:etech0
ID: 37738129
That must have been it.

Thanks a million!
0
 
LVL 61

Expert Comment

by:mbizup
ID: 37738135
Glad to help out :)
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question