View Full Version : Create a New query based on an existing query


Gulshan
06-08-2002, 05:51 AM
Hy,
I have a table in Access with fields “DATE”, “CODE” and “EXCH_RATE” where I everyday I import the exchange rates of each Currency Code. I have then create a query based on this table, where I make a ‘group by’ on “MONTH”, “YEAR”, “CODE” a count’ on “DATE” for each “CODE” and an ‘Average’ on “EXCH_RATE” so that I obtain the average exchange rate for each CODE for each Month. I will then need to export this to a .txt file.
But My problem is before I make this query and export the result to a .txt file I need to check that for each CODE I have 30,31,29,28 count depending on the month and year. If the count is not good, Its should display a msg saying that the count for such Currency Code is not correct and don’t export the file to a .txt file or stop the process of doing the average on the rates.

Please help me, its very urgent for me
Thanking you in anticipation

raskew
06-08-2002, 11:27 AM
1. When dealing with the same problem, continue your questions in the same thread, thus allowing folks who may respond the opportunity to see the progress of the situation.

2. The following uses the same logic as the previous response, in that it determines, from a month/year calculated field, the number of days in the particular month. The query counts the number of records for each month/code and returns true (-1) if # of records = days in month.


SELECT Month([eDate]) & "/" & Year([edate]) AS widget, tblEDates.Code, Avg(tblEDates.eRate) AS AvgOfeRate, Count([widget])=Day(DateSerial(Year(DateValue([widget])),Month(DateValue([widget]))+1,0)) AS widgetc
FROM tblEDates
GROUP BY Month([eDate]) & "/" & Year([edate]), tblEDates.Code;