Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

access open report criteria - error!

Posted on 2012-03-19
9
Medium Priority
?
371 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
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…

618 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