Solved

access open report criteria - error!

Posted on 2012-03-19
9
361 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
 
LVL 10

Author Comment

by:etech0
ID: 37738082
It's a number. I'll try passing a number.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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 500 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now