473,396 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

wildcard in QBE criteria causing data type mismatch error

this is driving me crazy. i need to use a form control as a criteria
in a select query, and the control's value is set depending upon what
a user selects in an option group on the form. the query results
should return information on either a single employee or all
employees.

the problem that i have is that if i type in "*" (but without quotes)
in the QBE criteria, it works fine. however, if i use Iif() to
determine whether or not there is a value in the control and then use
* if there is not, i get a "data type mismatch" error. the empID field
is a numeric field.....so, that makes sense, but i don't understand
why * works if typed in, but not if you use a function or a form
control. i suspect it's because of a string / numeric data type
difference.

the question boils down to how do i use "*" or "like *", by using Iif
or a function (i've also created a function that returns * and that
doesn't work either) without explicitly typing it in?

thanks for any help you can offer.
Nov 12 '05 #1
3 3950
this what you're after?
http://www.mvps.org/access/queries/qry0001.htm
Nov 12 '05 #2
See

http://www.mvps.org/access/queries/qry0001.htm

(Q) I'm using a control on a form as a parameter for my query. I've
defined the criteria in the query as

Forms!myForm!myControl

How do I set this up so that if the field is left blank, all records are
returned by the query?

(A) Change the criteria in the query to

Forms!myForm!myContrl OR forms!myForm!myControl Is Null

I also use

nz([parameter],[tablename].[fieldname])

so take your pick.

Peter


lk****@cox.net (Laurel) wrote in news:28aa456e.0310131706.1e334627
@posting.google.com:
this is driving me crazy. i need to use a form control as a criteria
in a select query, and the control's value is set depending upon what
a user selects in an option group on the form. the query results
should return information on either a single employee or all
employees.

the problem that i have is that if i type in "*" (but without quotes)
in the QBE criteria, it works fine. however, if i use Iif() to
determine whether or not there is a value in the control and then use
* if there is not, i get a "data type mismatch" error. the empID field
is a numeric field.....so, that makes sense, but i don't understand
why * works if typed in, but not if you use a function or a form
control. i suspect it's because of a string / numeric data type
difference.

the question boils down to how do i use "*" or "like *", by using Iif
or a function (i've also created a function that returns * and that
doesn't work either) without explicitly typing it in?

thanks for any help you can offer.


Nov 12 '05 #3
thanks to both of you!

i used
Forms!myForm!myContrl OR forms!myForm!myControl Is Null


and it worked like a charm. i'm new to this. obviously. thanks again!
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ArcadeJr | last post by:
Good morning all! I have been getting a Run-time Error message #3464 - Data Type mismatch in criteria expression. While trying to run a query. I have a database where the field Asset_Number...
2
by: igor.barbaric | last post by:
Hello! I have created a very simple query like this: SELECT Tasks.Name, DurationHrs(,) AS Duration FROM Tasks INNER JOIN Log ON Tasks.TaskID=Log.TaskID; The above query works fine....
1
by: Igor Barbaric | last post by:
Hello! I have created a very simple query like this: SELECT Tasks.Name, DurationHrs(,) AS Duration FROM Tasks INNER JOIN Log ON Tasks.TaskID=Log.TaskID; The above query works fine....
4
by: bleighfield | last post by:
Hi everyone Hope someone can help with this one.. Background: I work in vehicle fleet, I have built something to 'predict' when a car/van service is due (it's fairly simple, calculates...
10
by: aaronrm | last post by:
I have a real simple cross-tab query that I am trying to sum on as the action but I am getting the "data type mismatch criteria expression" error. About three queries up the food chain from this...
2
by: psychomad | last post by:
Please, can someone help me out to solve this error, i've been searching throughout my codes and yet i didnt succeed in finding the error!!!! The Error is: Server Error in '/' Application....
5
by: blackburnj55 | last post by:
Hi, I am constructing a website for a bike shop. I am using dreamweaver and an access database to create it. I have made a query where two criteria are entered to get results. These are :...
19
by: Lysander | last post by:
I have written a query that takes three integers representing day,month and year, forms a date from them and compares this date to the date the record was entered and returns any records where the...
9
by: nixonmg | last post by:
When the Command Button "Notify" is clicked, I am wanting to send out an email to the user with appropriate information in the email (works great), check the "Notified" check box (does not work), and...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.