T
Tony Williams
I have a main report that is based on a query qryreport1 and which has 6
subreports. There is one control on the main report, txtmonthlabel (a
date/time field in my table) which is used to link all the subreports. The
subreports are also based on the same query and have a number of controls
including txtmonthlabel and txtcompany. I have a form at the front end that
the user chooses to view records for all companies or chooses only one and
then chooses a date range. The sub reports should all look like this if the
user chooses to view all companies but only one company if they choose to
view a selected company:
Company1 (which is the txtcompany control )
March 2005........data1............data2...........data3
June 2005...........data1............data2...........data3
September 2005.data1............data2...........data3
December 2005..data1............data2...........data3
Company2
March 2005........data1............data2...........data3
June 2005...........data1............data2...........data3
September 2005.data1............data2...........data3
December 2005..data1............data2...........data3
etc etc etc
However what I'm getting is even if I choose just one company:
Company1
March 2005........data1............data2...........data3
Company2
March 2005........data1............data2...........data3
Company1
June 2005...........data1............data2...........data3
Company2
June 2005...........data1............data2...........data3
The code behind my OnClick event on the front end form is this
Private Sub cmdOK_Click()
Dim strReport As String 'Name of report to open.
Dim strField As String 'Name of your date field.
Dim strWhere As String 'Where condition for OpenReport.
Const conDateFormat = "\#mm\/dd\/yy\#"
strReport = "rptsense3"
strField = "txtmonthlabel"
If IsNull(Me.txtstartdate) Then
MsgBox "You must enter a start date", vbOKOnly, "Missing Start Date"
Me.txtstartdate.SetFocus
Else
If IsNull(Me.txtenddate) Then
MsgBox "You must enter an end date", vbOKOnly, "Missing End Date"
Me.txtenddate.SetFocus
Else
strWhere = strField & " Between " & Format(Me.txtstartdate,
conDateFormat) _
& " And " & Format(Me.txtenddate, conDateFormat)
If Not IsNull(Me.cmbselectcompany) Then
strWhere = strWhere & " AND cmbCompany = """ & Me.cmbselectcompany & """"
End If
DoCmd.OpenReport strReport, acViewPreview, , strWhere
End If
End If
End Sub
Sorry this is so long but I wanted to make sure you had all the relevant
facts. Hope I've not missed anything.
Any help would be appreciated.
Thanks
Tony
subreports. There is one control on the main report, txtmonthlabel (a
date/time field in my table) which is used to link all the subreports. The
subreports are also based on the same query and have a number of controls
including txtmonthlabel and txtcompany. I have a form at the front end that
the user chooses to view records for all companies or chooses only one and
then chooses a date range. The sub reports should all look like this if the
user chooses to view all companies but only one company if they choose to
view a selected company:
Company1 (which is the txtcompany control )
March 2005........data1............data2...........data3
June 2005...........data1............data2...........data3
September 2005.data1............data2...........data3
December 2005..data1............data2...........data3
Company2
March 2005........data1............data2...........data3
June 2005...........data1............data2...........data3
September 2005.data1............data2...........data3
December 2005..data1............data2...........data3
etc etc etc
However what I'm getting is even if I choose just one company:
Company1
March 2005........data1............data2...........data3
Company2
March 2005........data1............data2...........data3
Company1
June 2005...........data1............data2...........data3
Company2
June 2005...........data1............data2...........data3
The code behind my OnClick event on the front end form is this
Private Sub cmdOK_Click()
Dim strReport As String 'Name of report to open.
Dim strField As String 'Name of your date field.
Dim strWhere As String 'Where condition for OpenReport.
Const conDateFormat = "\#mm\/dd\/yy\#"
strReport = "rptsense3"
strField = "txtmonthlabel"
If IsNull(Me.txtstartdate) Then
MsgBox "You must enter a start date", vbOKOnly, "Missing Start Date"
Me.txtstartdate.SetFocus
Else
If IsNull(Me.txtenddate) Then
MsgBox "You must enter an end date", vbOKOnly, "Missing End Date"
Me.txtenddate.SetFocus
Else
strWhere = strField & " Between " & Format(Me.txtstartdate,
conDateFormat) _
& " And " & Format(Me.txtenddate, conDateFormat)
If Not IsNull(Me.cmbselectcompany) Then
strWhere = strWhere & " AND cmbCompany = """ & Me.cmbselectcompany & """"
End If
DoCmd.OpenReport strReport, acViewPreview, , strWhere
End If
End If
End Sub
Sorry this is so long but I wanted to make sure you had all the relevant
facts. Hope I've not missed anything.
Any help would be appreciated.
Thanks
Tony