473,401 Members | 2,146 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,401 software developers and data experts.

Getting a query to use a number of values as criteria (A OR B OR C etc) which are stored in another table.

This might be a little complicated to explain. I have a table
(Paddocks) with 4 property codes as fields. In each of these fields is
a list of paddocks (varying number). My code at the moment runs this
query 4 times (for each property), and I need the parameters of the
query to change depending on which property is being checked. The
reason I don't just type the properties in as criteria is because I
want the user to be able to add paddocks to the table and for them to
be automatically included in the query next time it is run. Any ideas
much appreciated...

Cheers

Reg

Nov 13 '05 #1
4 1387
Not sure I follow... but you could do something like specify a table
and a field and return a list of delimited values and maybe pass that
to the query as a criterion... Would help if you gave an example of
criteria and query. hard to figure it out from what you've given.

Nov 13 '05 #2
This is the SQL of the query...

SELECT Herd_Animals.Owner, Herd_Animals.Animal_Tag,
Herd_Animals.PurchaseDate, Herd_Animals.Group2_Code,
Herd_Animals.Grade, Herd_Animals.Sex_Code, Herd_Animals.Location_Code
INTO QTable3
FROM Herd_Animals
WHERE (((Herd_Animals.PurchaseDate)>=[Forms]![Form1]![TxtStartDate] And
(Herd_Animals.PurchaseDate)<=[Forms]![Form1]![TxtEndDate]) AND
((Herd_Animals.Location_Code)=[PropertyExternalMovements]![DGS]));

It's that last bit - the table is PropertyExternalMovements, DGS is the
property code. I want the query to sort and return only those
Location-Code(s) which are found in the PropertyExternalMovements table
under "DGS". By the way, DGS is from "Herd_Animals.Owner" as well - if
it could reference to "Herd_Animals.Owner" field, that'd be ideal. Does
that help explain? And by the way, thanks for your help with this and
the last question.

Nov 13 '05 #3
Regnab wrote:
This is the SQL of the query...

SELECT Herd_Animals.Owner, Herd_Animals.Animal_Tag,
Herd_Animals.PurchaseDate, Herd_Animals.Group2_Code,
Herd_Animals.Grade, Herd_Animals.Sex_Code, Herd_Animals.Location_Code
INTO QTable3
FROM Herd_Animals
WHERE (((Herd_Animals.PurchaseDate)>=[Forms]![Form1]![TxtStartDate] And
(Herd_Animals.PurchaseDate)<=[Forms]![Form1]![TxtEndDate]) AND
((Herd_Animals.Location_Code)=[PropertyExternalMovements]![DGS]));

It's that last bit - the table is PropertyExternalMovements, DGS is the
property code. I want the query to sort and return only those
Location-Code(s) which are found in the PropertyExternalMovements table
under "DGS". By the way, DGS is from "Herd_Animals.Owner" as well - if
it could reference to "Herd_Animals.Owner" field, that'd be ideal. Does
that help explain? And by the way, thanks for your help with this and
the last question.


Piet has probably already posted the answer to this by now, but perhaps
try ending with:

AND (Herd_Animals.Location_Code) IN (SELECT DISTINCT DGS FROM
PropertyExternalMovements WHERE DGS IS NOT NULL);

instead of:

AND ((Herd_Animals.Location_Code)=[PropertyExternalMovements]![DGS]));

James A. Fortune

Since the [SMTP/ESMTP] message headers are given to the server twice
(once in the envelope and again in the message headers), a loophole for
spammers exists. One would hope that a modern server implementation
would not only validate the sender in the envelope, but also reject
messages where the sender as given in the envelope fails to match the
sender's address in the TO or Reply-To message headers. --- Dan Wood,
Programming Internet Email, O'Reilly 1999, ISBN 1-56592-479-7

Nov 13 '05 #4
BRILLANT. Spot on. Cheers mate....

Nov 13 '05 #5

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

Similar topics

1
by: Spidah | last post by:
Is there an easier way to get the number of items in a database table than selecting all the records in it and then running mysql_num_rows on the result? Hamilton www.laughland.biz
2
by: maceo | last post by:
I have a script that will print out the results of a table and make a calculation of a total of one of the columns. See example: <?php /* Database connection */...
0
by: maceo | last post by:
I have some code that extracts the data from a table and performs a calculation (total time) on one of the columns. Here is the code: <?php /* Database connection */
1
by: Tony Johnson | last post by:
I want to update a particular field in a form for only a certain set of records. The certain set of records is named Financed. I need to update those Financed records with a financed number that...
5
by: Sami | last post by:
Please bear with me, and if you answer this question, please do it step by step. I am new at Access, not at all sophisticated. I am using Office XP. This will need to be read in Access for...
5
by: Jack | last post by:
Hi, I am trying to find rows where a memo field in table1 contains the text in table2. Example: table1.memo contains: row 1: This is a long sentence that goes on and on... row 2: This is...
6
by: Sven Pran | last post by:
Probably the answer is there just in front of me only awaiting me to discover it, but: 1: I want to build a query that returns all records in one table for which there is no successful "join"...
0
by: MLH | last post by:
I have an A97 query (qryVehiclesNowners2) that has a table field in it named . Depending on the selections made in a number of criteria choices on a form, a field on the form will have string...
7
by: rcamarda | last post by:
I wish to build a table based on values from another table. I need to populate a table between two dates from another table. Using the START_DT and END_DT, create records between those dates. I...
0
by: barkarlo | last post by:
I make pivot table in excel. in page field is item month. in row field is employees. in column field is working hours,sunday hours, overtime and ect. Now I want with VBA code copy/paste only...
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
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: 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
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
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
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.