Help with date sorting and crosstab query

E

Eric Blitzer

windows 2000
Office 2000

I have a table with3 fields
Staff
Schedule Date
Timein - Out

I am able to produce a cross tab query with the following
results

Staff 11/1 11/10 11/11 ....
John 8:00 to 4:45 8:00 to 4:45 8:00 to 4:45
Joe 7:30 to 4:15 7:30 to 4:15 7:30 to 4:15

The order accross should be 11/1 11/2 11/3... I
understand the alpha sort and why it is putting 11/10 after
11/1. How do I get around this and sort accross the page
by date.

Also I would like to produce a report based on this
croostab query. The dates will always be changing. How do
I create this report.

Below is the sql

TRANSFORM Max([Rpt Schedule accross].Schedule) AS MaxOfSchedule
SELECT [Rpt Schedule accross].Staff
FROM [Rpt Schedule accross]
GROUP BY [Rpt Schedule accross].Staff
ORDER BY Format([ScheduledDate],"m/d")
PIVOT Format([ScheduledDate],"m/d");

Thanks

Eric
 
E

Edward G

On your first question, don't accept the formatting default which is
probably "short date" in your crosstab query. Change it to "mm/dd/yy".

Ed G
 
D

Duane Hookom

Try not to use "absolute" column headings for dates. You could possibly use
"relative" dates. For instance:
Form: frmA
Text Box: txtEndDate
Table: tblSales
Field: SaleDate
You want to show 12 months of sales in columns of a crosstab report.
Set the with menuing: Query|Parameter
Forms!frmA!txtEndDate Date/Time

Use this expression for your Column Headings:
ColHead:"Mth" & DateDiff("m",[SaleDate],Forms!frmA!txtEndDate)

This will produce Mth0, Mth1, Mth2, Mth3,... where Mth0 is sales from the
same month as the ending date on your form. Mth1 is the previous month etc.

Set your queries Column Headings property to:
"Mth0", "Mth1", "Mth2", "Mth3",.., "Mth11"
Build your report based on these "relative" months. If you need column
labels in your report, use text boxes with control sources of:
=DateAdd("m",0,Forms!frmA!txtEndDate)
=DateAdd("m",-1,Forms!frmA!txtEndDate)
=DateAdd("m",-2,Forms!frmA!txtEndDate)
=DateAdd("m",-3,Forms!frmA!txtEndDate)
...
This solution requires no code and will run fairly quickly. You should be
able to modify this for day intervals as opposed to month intervals.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top