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
Solved

access open report criteria - error!

Posted on 2012-03-19
9
365 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

856 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