Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query?-one date 3 fields checked within a table

Status
Not open for further replies.

techexpressinc

Programmer
Oct 28, 2008
67
US
How would I make it so one date enter on the query would hit 3 fields within one query.

Currently, the process is one date is entry and goes against one field of the one table.

We need the one date to go against 3 fields on the one table.

Let me know some direction please. Thanks for all your help.
Russ @ Scaninc.org
 
Is this a question about query criteria? It sounds suspiciously like the database is not normalized.
 
What do you mean not normalized?

It is a MS-Access db with a table with 3 fields that hold dates.

We want to query the table with date between i.e. 09/01/2008 to 12/01/2008, then any records in any of the 3 fields be displayed.

Currently, the query runs against one field, I need to add the other 2 fields within a record to the query. And was wondering how?

Russ
 
What is your actual SQL code and fields names ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
All tables in an Access database, or relational database, must be normalized before anything else. Here's a start to study normalization:
Fundamentals of Relational Database Design

You state you have three date fields. Why? This violates the first normal form of repeating column headings, date, date, date. Also, leads to variable length records, category as fields and not column, etc.

What do these date fields refer to??
 
The 3 dates fields have different names within the same table.

i.e.
reporting-needed-date1
reporting-needed-2nd-time-date2
reporting-needed-2nd-time-date3
 
reporting-needed-date1
reporting-needed-2nd-time-date2
reporting-needed-2nd-time-date3

"different names". No, they have the same name - date, date, date. So should be three records, not fields. Again, you have a category laid out horizontally. Thus your problem. You can do a union query on the three dates to get it in a correct format then run the between function.
 
SELECT * FROM yourTable
WHERE [reporting-needed-date1] Between #2008-09-01# And #2008-12-01#
OR [reporting-needed-2nd-time-date2] Between #2008-09-01# And #2008-12-01#
OR [reporting-needed-2nd-time-date3] Between #2008-09-01# And #2008-12-01#

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I think I got it. First, make all the fields date format.
Then,
In query design below date1 have the parameter would be:
"Between [beginning date] And [ending date]"

Then in query design below date2 field in the "or" row on the left would be:
"Between [beginning date] And [ending date]"

Then in query design below date3 field in the same "or" row would be:
"Between [beginning date] And [ending date]"

Does this sound correct?
Thx Russ
 
No, you should have 3 criteria rows (ie 2 "or" rows)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top