By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,276 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

How to query database with multiple queries

P: n/a

I have the following fieldname in an Access_Table:

Field 1 = Cust_ID (Primary key)
Field 2 = Date
Field 3 = Description
Field 4 = Inv_No
Field 5 = Amount

My SQL Input syntax are:

"Select distinct Cust_ID,Date,Description,Inv_No,Amount from
Access_Table WHERE Date <Now()-30 And Date >Now()-60 AND Date =
Main.Date"

It failed to generate the result I want,anyway

My "Required" Output is:

Cust_ID Date Description Inv_No >30DYS >60DYS
8000 21/05/2004 PC RAM 200
8000 26/06/2004 Modem 180
---------------------------------------------------------------
Total: 180 200
---------------------------------------------------------------

8001 22/04/2004 Cable 50
8001 23/05/2004 HD 210
---------------------------------------------------------------
Total: 260
---------------------------------------------------------------
Grand Total: 180 460
can anyone help? Thanks
From:Cady Steldyn

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi Cady,
One problem you're having here is calling a field with the name of "Date"
which is a reserved word in Access. Rename this field to DatePaid or
StartDate or DateProcessed etc. This give the field name more uniqueness and
at a quick glance, anybody can understand what the purpose of the field is
for.

With your SQL syntax and using the "Date" field renamed to DatePaid
***Warning Untested Air Code***
SELECT Cust_ID, DatePaid, Description, Inv_No, Amount
FROM Access_Table
WHERE DatePaid Between DateAdd("d", -60, Date()) And DateAdd("d", -30,
Date());

The Date() function represents the current date while the Now() function
represents the current date and current time.

Jeff
"Cady Steldyn" <dc*******@yahoo.ca> wrote in message
news:41**********************@news.newsgroups.ws.. .

I have the following fieldname in an Access_Table:

Field 1 = Cust_ID (Primary key)
Field 2 = Date
Field 3 = Description
Field 4 = Inv_No
Field 5 = Amount

My SQL Input syntax are:

"Select distinct Cust_ID,Date,Description,Inv_No,Amount from
Access_Table WHERE Date <Now()-30 And Date >Now()-60 AND Date =
Main.Date"

It failed to generate the result I want,anyway

My "Required" Output is:

Cust_ID Date Description Inv_No >30DYS >60DYS
8000 21/05/2004 PC RAM 200
8000 26/06/2004 Modem 180
---------------------------------------------------------------
Total: 180 200
---------------------------------------------------------------

8001 22/04/2004 Cable 50
8001 23/05/2004 HD 210
---------------------------------------------------------------
Total: 260
---------------------------------------------------------------
Grand Total: 180 460
can anyone help? Thanks
From:Cady Steldyn

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.