Stewart_HendersonNO1
asked on
Selecting dates in query
Hi,
Each day data is added to a table, which I have extracted in a crosstab query in the format below -
I then link this data below to another query, but how can I automatically include all the days in this new query without adding them manually each day
first_name surname emp_no From 0500312 19/03/2012
David Franklin WO055 2030 316 59.75
Below is the sql from the new query - how can this be modified to include all dates from 050312, currently it only shows up to the 19th but the 20th is already in the crosstab table.
SELECT tblCrosstab050312.first_na me, tblCrosstab050312.surname, tblCrosstab050312.emp_no, tblCrosstab050312.Allocate d_Hrs, tblCrosstab050312.Hrs_Jan_ Mar, tblCrosstab050312.[Total Hrs From 050312], tblCrosstab050312.Remainin g_Hrs, tblCrosstab050312.[19/03/2 012], tblCrosstab050312.[16/03/2 012], tblCrosstab050312.[15/03/2 012], tblCrosstab050312.[14/03/2 012], tblCrosstab050312.[13/03/2 012], tblCrosstab050312.[12/03/2 012], tblCrosstab050312.[09/03/2 012], tblCrosstab050312.[08/03/2 012], tblCrosstab050312.[07/03/2 012], tblCrosstab050312.[06/03/2 012], tblCrosstab050312.[05/03/2 012]
FROM tblCrosstab050312;
Each day data is added to a table, which I have extracted in a crosstab query in the format below -
I then link this data below to another query, but how can I automatically include all the days in this new query without adding them manually each day
first_name surname emp_no From 0500312 19/03/2012
David Franklin WO055 2030 316 59.75
Below is the sql from the new query - how can this be modified to include all dates from 050312, currently it only shows up to the 19th but the 20th is already in the crosstab table.
SELECT tblCrosstab050312.first_na
FROM tblCrosstab050312;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do you not use the query design grid?
The query type is selectable once you have your basic select query defined.
The query type is selectable once you have your basic select query defined.
SELECT * INTO tableToMake
FROM CrossTabTable;
FROM CrossTabTable;
ASKER
Hi,
My issue all along has been how I can get specific data from a tbl and have it arranged in a specifc order, if it wasn't for the fact a new date is added to the original table each day then I could do it via the design view comfortably.
I have enclosed the tbl in question, I wish to extract in a query in the following order -
First Name, Surname, Emp_No, Alloc_Hrs, Hrs_Jan_Mar,Total Hrs, Remaining, then all the dates in descending order
As mentioned each day a new date is added to the table and I do not want to manually add this to the query (just selecting * will not give me the sort order)
Help much appreciated
Database2.mdb
My issue all along has been how I can get specific data from a tbl and have it arranged in a specifc order, if it wasn't for the fact a new date is added to the original table each day then I could do it via the design view comfortably.
I have enclosed the tbl in question, I wish to extract in a query in the following order -
First Name, Surname, Emp_No, Alloc_Hrs, Hrs_Jan_Mar,Total Hrs, Remaining, then all the dates in descending order
As mentioned each day a new date is added to the table and I do not want to manually add this to the query (just selecting * will not give me the sort order)
Help much appreciated
Database2.mdb
OK so the nub of the issue is field order.
I that case I can see that you have a problem. I can't see any simple change to get what you want.
I think you will have to build the select query in code.
It seems to me that you would have to get a list of distinct date field values from the table, and from that build a list of field names which can be used to build a complete sql query to select from the crosstab query.
I that case I can see that you have a problem. I can't see any simple change to get what you want.
I think you will have to build the select query in code.
It seems to me that you would have to get a list of distinct date field values from the table, and from that build a list of field names which can be used to build a complete sql query to select from the crosstab query.
ASKER
I used this answer and with some more work carried out by myself a solution has now been achieved.
ASKER
This syntax below was previously a make table query, now using the Select * gets me all the dates but how can I also make it a make table query (tblCrosstab050312)
SELECT *
FROM qryEngineeringHrs050312_Cr
Thanks