473,387 Members | 1,897 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,387 software developers and data experts.

Setting criteria on an expression in a query

I have a query with an expression that compares [SoldDate] to today's date and displays a value in months using the DateDiff() function. I have a second expression to evaluate the first expression and assign a letter based on the value. It would either assign: A,B,C, or D. The query is running correctly at this point.

The problem I am having is I need to set a criteria on the second expression. It is simply = "C". When I try to set the criteria, I get a parameter prompt for the first expression.

Any ideas why this is occuring?

In reality, I don't need to use the second expression. However it would be nice.
Dec 22 '11 #1

✓ answered by TheSmileyCoder

I think I had a similar issue once, where I found that creating a query calculating the SoldDateDiff, and then using that query in another query solved the issue.

I dont know if its "best" way of doing it, but as I recall it worked for me.

7 1677
TheSmileyCoder
2,322 Expert Mod 2GB
Have you tried it without the = sign? Just plainly writing "c" with the quotes?
Dec 22 '11 #2
Thanks, The Smiley Coder. It still causes the parameter issue.
Dec 22 '11 #3
TheSmileyCoder
2,322 Expert Mod 2GB
I think I had a similar issue once, where I found that creating a query calculating the SoldDateDiff, and then using that query in another query solved the issue.

I dont know if its "best" way of doing it, but as I recall it worked for me.
Dec 22 '11 #4
Thats the approach I have came to also. Thank You!!!

Have a happy holiday TheSmileyCoder
Dec 22 '11 #5
NeoPa
32,556 Expert Mod 16PB
I told you that in the other thread when I posted the code for you :-D I swear that half of what I write is either ignored or misunderstood.

The reason the value is prompted is because of the order that different parts of the SQL run in. Before it gets to the SELECT clause, it must determine if a record qualifies even to be looked at (The WHERE clause), and if so, how it will be grouped (The GROUP BY and ORDER BY clauses). Your [SoldDateDiff] field is determined in the SELECT clause, after the value of the [SoldDateDiffGrp] field is checked in the GROUP BY clause. At that point the SELECT clause has not processed so the references to [SoldDateDiff] are not understood, therefore causing the prompt.

Subqueries (See Subqueries in SQL) are fully determined by the time the outer query tries to access any part of them, so using a subquery (or a named and saved query) as your record source ensures all these values are available in all the clauses.

Does that make the situation clearer?
Dec 22 '11 #6
NeoPa,

This explaination you have provided makes the issue much easier to understand. Your advice is always appriciated. At times I feel that the explainations are "over my head" but the more I read them the clearer they become.

As always, thanks for your help.

Have a great holiday season!
Dec 23 '11 #7
NeoPa
32,556 Expert Mod 16PB
I'm happy to hear that, and wish you too a happy holiday season.

Remember though, if there's something any of us says that you don't understand, the best idea is to ask for clarification. Generally (if not always), we'll be happy to clarify.
Dec 24 '11 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: s_gregory | last post by:
The mdb is considerable size 70 +- mb. A complex union query was working well, but when an additional union select... was added into the query, selecting identical fields from a different source,...
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 :...
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...
12
by: gravesk | last post by:
Hello - I am a novice in MS Access and do not know SQL. I am using Access 2003. I have set up two queries that seem to be working fine. Each comes directly from a table. I have joined the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.