Report sort

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table that contains a field "datesold". I want a report not only to
sort by week, which I did with--=Format$([DateSold],"ww",0,0), I also would
like to further sort by the day of the week. I am very much a beginner. Any
help would be appreciated.
 
Did you use the wizard to make the report? You can add more than one grouping level of a field if you click its name twice in the "grouping levels" section of the wizard.
 
I have a table that contains a field "datesold". I want a report not only to
sort by week, which I did with--=Format$([DateSold],"ww",0,0), I also would
like to further sort by the day of the week. I am very much a beginner. Any
help would be appreciated.

Don't confuse data DISPLAY with data sorting. The Format$() function returns a
text string (so, for example, week "9" will sort after week "10").

If you want the records sorted chronologically just sort by [DateSold] in the
Report's Sorting and Grouping dialog. You can display the date any way you
like; you don't need to use the Format$() function in your query, just set the
Format property of the report textbox.

John W. Vinson [MVP]
 
As John has pointed out if you merely wish to order the rows then you can
simply sort the report by the DateSold column. If, however, you wish to
'group' it by week so as to be able to include aggregated values per week in
a header or footer, or simply to separate each week visually, then use the
DatePart function, which returns an integer number rather than a string data
type. This takes an interval argument which is "ww" for week, and you can
then simply sort or group by DateSold as the next group level. Remember that
if your data spans the end of a year simply grouping by intervals like week
or month will put the rows from the end of the first year after those at the
start of the next, so to cater for this possibility group the data by year as
the first group level either by using "yyyy" as the interval argument of the
DatePart function or by using the Year function. Then group by week as the
next group level.

One more caveat: there is actually no such thing in Access as a 'date
value' per se only 'date/time values'. A value entered as a date is in fact
a point of time at midnight at the start of the day. Sometimes a non-zero
time of day can creep in without you being aware of it if steps have not been
taken to prohibit values with non-zero times of day in the column (the
inappropriate use of the Now function as a default value is a common
culprit). If this has happened then grouping by DateSold would put values
with different times of day on the same day in separate groups. You can
guard against this by using the DateValue function for the grouiping, which
returns the date with a zero time of day element, (or even the Int function
for that matter as date/time values are in fact 64 bit floating point numbers
under the skin (as an offset from 30 December 1899 00:00:00) with the days
represented by the integer part and the times of day by the fractional part).

Ken Sheridan
Stafford, England
 

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

Back
Top