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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have query and I want to just pul

Status
Not open for further replies.

zaq888

MIS
Jun 2, 2003
46
0
0
MY
I have query and I want to just pull records from a certain month. I want to run the query once a month and have the user select the month and year from the combo box in the parameter (the month that just ended usually) Does anyone know how to do this without going into design view and using hte between date way.

before this, i'm using this query to pick data from date between ? and ? using date picker.
==> WHERE Tdata.date BETWEEN ? AND ?. ? represent datepicker1.value and datepicker2.value

SELECT TUnit.[cs-username]
FROM TUnit LEFT JOIN [SELECT * FROM Tdata WHERE Tdata.date BETWEEN ? AND ?]. AS MyTempTbl ON TUnit.[cs-username] = MyTempTbl.[cs-username]
WHERE (((MyTempTbl.[cs-username]) Is Null))
ORDER BY Tunit.[cs-username];

so how can i catch all data for the whole month?

I'm Keep Studying.... please show the way...
Not Good in English
 
If you want this query to always run the month that has just ended this can be done without any prompting of the user for input:
SELECT * FROM Tdata WHERE Tdata.date BETWEEN DateSerial(DatePart("yyyy",DateAdd("m",-1,Date())),DatePart("m",DateAdd("m",-1,Date())),1) and DateAdd("d",(DatePart("d",Date())+1)*-1,Date());

The above should be saved as a Query with a name. Then perform the INNER JOIN with your other table using the common fields. The use of the sub select query within the query as you were trying will not work. ACCESS does not recognize your select within the square brackets as a valid query. So, just save it and use it as a saved query.

Bob Scriver

Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
thanks a lot. somehow the code is helping me.. i have made some changes...

Thanks scriverb....

I'm Keep Studying.... please show the way...
Not Good in English
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top