B
BruceM
I am doing some work in a Customer Calls database. Oversimplifying a bit,
calls are either complaints or compliments. I am using the click event of a
command button on an unbound form (frmParameter) to provide a date range
directly (rather than providing query criteria) using a slight adaptation of
code Allen Browne provided on his web site:
Dim strReport As String 'Name of report to be opened
Dim strField As String 'Name of date field
Dim strWhere As String 'Where condition for OpenReport
Const conDateFormat = "\#mm\/dd\/yyyy\#"
strReport = "rptFeedback"
strField = "FeedbackDate"
If IsNull(Me.txtStart) And IsNull(Me.txtEnd) Then
DoCmd.OpenReport strReport, acViewPreview
Else
If Not IsNull(Me.txtEnd) And IsNull(Me.txtStart) Then 'End
date only; no Start
strWhere = strField & " <= " & Format(Me.txtEnd,
conDateFormat)
Else 'Start and End dates provided
strWhere = strField & " Between " & Format(Me.txtStart,
conDateFormat) & _
" And " & Format(Me.txtEnd, conDateFormat) And
Me.grpSelectAll = 3
End If
End If
DoCmd.OpenReport strReport, acViewPreview, , strWhere
I would also like to give the users a choice between Complaints only,
Compliments only, and All (both complaints and compliments). To that end I
have provided an option group on frmParameter, with the idea that I can
specify All, Complaint, or Compliment in addition to the date range (the
default is All). Complaint_Compliment is a text field. I would rather not
use an assortment of queries to accomplish this, so I guess I am trying to
figure out how to specify the parameters dynamically. Especially vexing has
been my attempt to specify a value for the Complaint_Compliment text field
in something like this:
strSQL = "SELECT * from tblCalls WHERE Complaint_Compliment = ???"
calls are either complaints or compliments. I am using the click event of a
command button on an unbound form (frmParameter) to provide a date range
directly (rather than providing query criteria) using a slight adaptation of
code Allen Browne provided on his web site:
Dim strReport As String 'Name of report to be opened
Dim strField As String 'Name of date field
Dim strWhere As String 'Where condition for OpenReport
Const conDateFormat = "\#mm\/dd\/yyyy\#"
strReport = "rptFeedback"
strField = "FeedbackDate"
If IsNull(Me.txtStart) And IsNull(Me.txtEnd) Then
DoCmd.OpenReport strReport, acViewPreview
Else
If Not IsNull(Me.txtEnd) And IsNull(Me.txtStart) Then 'End
date only; no Start
strWhere = strField & " <= " & Format(Me.txtEnd,
conDateFormat)
Else 'Start and End dates provided
strWhere = strField & " Between " & Format(Me.txtStart,
conDateFormat) & _
" And " & Format(Me.txtEnd, conDateFormat) And
Me.grpSelectAll = 3
End If
End If
DoCmd.OpenReport strReport, acViewPreview, , strWhere
I would also like to give the users a choice between Complaints only,
Compliments only, and All (both complaints and compliments). To that end I
have provided an option group on frmParameter, with the idea that I can
specify All, Complaint, or Compliment in addition to the date range (the
default is All). Complaint_Compliment is a text field. I would rather not
use an assortment of queries to accomplish this, so I guess I am trying to
figure out how to specify the parameters dynamically. Especially vexing has
been my attempt to specify a value for the Complaint_Compliment text field
in something like this:
strSQL = "SELECT * from tblCalls WHERE Complaint_Compliment = ???"