Sorting by date in a report

P

Paul M

I thought I was done (sorry guys), but now I have been given another task....

before I asked for help in sorting "Associates" and "Dates" and now I have
been given a new task to make a button sort by just the date for all
Associates.

this is the cdoe I have for the other button

Dim strWhere As String
strWhere = "[Associate] = '" & Me.cboAssociate & _
"' AND [Call Date] BETWEEN #" & Me.FromDate & "# AND #" & _
Me.ToDate & "#"
DoCmd.OpenReport "Associate Appointment Listing", acViewNormal, , strWhere
DoCmd.Close

Same Report this time I just need to sort by date, thanks in advance
 
J

John Spencer

Do you mean SORT or do you mean SELECT? Your posted code SELECTS a group of
records and has nothing to do with the order the records are sorted (display
order).

If you mean SELECT, then all you need to do is change StrWhere so it doesn't
include the [Associate] criteria.

strWhere = "[Call Date] BETWEEN #" & Me.FromDate & "# AND #" & Me.ToDate &
"#"
 
P

Paul M

Thank you Alan and John,

both were very helpful in creating a solution for my database

Code used.......

Private Sub cmdListing_Click()

Dim strWhere As String
strWhere = "[Call Date] BETWEEN #" & Me.FromDate & "# AND #" & Me.ToDate
& "#"
DoCmd.OpenReport "Call Center Listing", acViewNormal, , strWhere
DoCmd.Close
End Sub

I knew this forum would have an answer as it always does A++++++

John Spencer said:
Do you mean SORT or do you mean SELECT? Your posted code SELECTS a group of
records and has nothing to do with the order the records are sorted (display
order).

If you mean SELECT, then all you need to do is change StrWhere so it doesn't
include the [Associate] criteria.

strWhere = "[Call Date] BETWEEN #" & Me.FromDate & "# AND #" & Me.ToDate &
"#"

Paul M said:
I thought I was done (sorry guys), but now I have been given another
task....

before I asked for help in sorting "Associates" and "Dates" and now I have
been given a new task to make a button sort by just the date for all
Associates.

this is the cdoe I have for the other button

Dim strWhere As String
strWhere = "[Associate] = '" & Me.cboAssociate & _
"' AND [Call Date] BETWEEN #" & Me.FromDate & "# AND #" & _
Me.ToDate & "#"
DoCmd.OpenReport "Associate Appointment Listing", acViewNormal, ,
strWhere
DoCmd.Close

Same Report this time I just need to sort by date, thanks in advance
 
Top