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

Problem with a Union of two criteria in a query

Hi,

I am writing a query that should prompt a user for the name or the ID
of an application. I put the same prompt text in the criteria column
of the Application ID and the "or" column of the Name column.

The SQL view shows the following text:

HAVING ((([Test Runs].[Application ID])=[Enter Application name or
ID])) OR (((Applications.Name)=[Enter Application name or ID]));

When I insert an Application number, it works fine, but when I enter
text in response to the prompt, I get the "The expression is typed
incorrectly or is too complex to evaluate..." error.

Having a criterion for only one of the fields works fine with either
the name or the ID. When I put the two together (OR them) the order
doesn't matter. It doesn't work with either.

Thanks
Nov 13 '05 #1
1 1562
"Jimmy123" <yo*******@gmail.com> wrote in message
news:9a**************************@posting.google.c om...
Hi,

I am writing a query that should prompt a user for the name or the ID
of an application. I put the same prompt text in the criteria column
of the Application ID and the "or" column of the Name column.

The SQL view shows the following text:

HAVING ((([Test Runs].[Application ID])=[Enter Application name or
ID])) OR (((Applications.Name)=[Enter Application name or ID]));

When I insert an Application number, it works fine, but when I enter
text in response to the prompt, I get the "The expression is typed
incorrectly or is too complex to evaluate..." error.

Having a criterion for only one of the fields works fine with either
the name or the ID. When I put the two together (OR them) the order
doesn't matter. It doesn't work with either.


Whatever you enter is going to be applied to BOTH criteria. The following will
be properly parsed by Access...

HAVING ((([Test Runs].[Application ID])=123)) OR (((Applications.Name)=123));

....because it will implicitly convert the entry (1) to the string "1". When
given the following though...

HAVING ((([Test Runs].[Application ID])="SomeName")) OR
(((Applications.Name)="SomeName"));

....Access encounters a type mismatch error in the first part because you are
comparing a string to a numeric field.

Your needs are sufficiently complex that I recommend dropping the use of a
parameter query and instead providing a form for the user to specify the
criteria. Self-prompting parameter queries are only well suited to the simplest
of situations and are rarely used in a production quality application.

With a form you could have a ComboBox that displays the Application Name, but
actually evaluates to the Application ID so the user can always use the name,
but your criteria can always use the ID.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com

Nov 13 '05 #2

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

Similar topics

5
by: Alicia | last post by:
Hello everyone based on the data, I created a union query which produces this. SELECT ,,, 0 As ClosedCount FROM UNION SELECT ,, 0 AS OpenedCount, FROM ORDER BY , ;
3
by: Chip R. | last post by:
Hi, This isn't really an access question, but as I'm really new to SQL I don't know where I would post this. Any suggestions on that would also be helpful. Now on to the question... I am...
5
by: hubmei75 | last post by:
Hello, I have a simple table containing adresses. A sample view of the table is id name city -------------------------------- 100 Meier New York 101 Meier Tokyo 110 ...
3
by: NoodNutt | last post by:
G'day ppl. Can anyone assist me with the correct structure of the following in a Union Query. tblBookings.FinYear tblBookings.DepPrefPay tblBookings.IntPrefPay tblBookingsFinPrefPay
1
by: BerkshireGuy | last post by:
I have the following union query that runs great. I want to be able to return the returns where the TEST field is True (-1) How do I add criteria to do this without using another query? SELECT...
0
by: RSN | last post by:
I hav a query that uses a union of 16 tables to get some counts and i need to get the end result as a Group by. This is inside a sub-query that has the count(*) ans the attribute for the group-by in...
5
by: ilikebirds | last post by:
Is it possible to create a union query that contains criteria from another union query? I would like the query to only display the order numbers from TeamUnions that are either contained in...
1
by: ebasshead | last post by:
Hi Everyone I have four queries that Ive joined in a union query and want to add a date criteria ei between and including date A and date B. Ive tried a few things but getting errors. Can someone...
2
by: MLH | last post by:
Consider having tblCorrespondence, then copying & pasting it to tblCorrespondence1 - such that they are identical. Then consider the following UNION SELECT statement... SELECT...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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...

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.