G
Gordon
I am designing a report which lists a schedule of visits for a period
of 2 weeks (defined by user input to a dialog box), with the data
presented by week. The code for the report is configured "on the fly"
in the 'on open' event of the report. All of this works fine on its
own. However, I am seeking to make some enhancements to this.
1. If there is no data for either week, I want a message to appear to
say just this. I am using a count of the underlying recordset to
determine this. Can't get the "On No data" report event to work with
the code below.
2. If there is no data for one or other week, I want a message to pop
up saying this, the report to print anyway and for an appropriate
caption to appear in the report header.
The coding I have so far is:
......lots of code here setting up variables etc
......strSQL1 is the string I use for selecting the records for the 2
week period and rst1 is the corresponding recordset
......strSQL2 is the string I use for selecting records for the second
week, rst 2 the recordset and so on for strSQL3 for week 3
Set dbs = currentdb
Set rst1 = dbs.OpenRecordset(strSQL1, dbOpenSnapshot)
If rst1.RecordCount = 0 Then
Call MsgBox("There is no data for this report@@ Please select new or
valid_
criteria", 16, "Message")
Cancel = True
Exit Sub
End If
Set rst2 = dbs.OpenRecordset(strSQL2, dbOpenSnapshot)
Set rst3 = dbs.OpenRecordset(strSQL3, dbOpenSnapshot)
If rst2.RecordCount = 0 or rst3.RecordCount = 0 Then
NoDataLabel.Visible = True 'Report header label
Call MsgBox("There is no data for the second week of this schedule.",
16,_
"Message")
End If
'Initialize SELECT statement.
MyRecordsource = strSQL
Set RecordSource property of Details Report.
Reports!rptBookingSchedule.RecordSource = MyRecordsource
DoCmd.Maximize
End Sub
The reporting of the basic data by week or 2 weeks works fine but not
the recordset criteria. Where am I going wrong?
Thanks
Gordon
of 2 weeks (defined by user input to a dialog box), with the data
presented by week. The code for the report is configured "on the fly"
in the 'on open' event of the report. All of this works fine on its
own. However, I am seeking to make some enhancements to this.
1. If there is no data for either week, I want a message to appear to
say just this. I am using a count of the underlying recordset to
determine this. Can't get the "On No data" report event to work with
the code below.
2. If there is no data for one or other week, I want a message to pop
up saying this, the report to print anyway and for an appropriate
caption to appear in the report header.
The coding I have so far is:
......lots of code here setting up variables etc
......strSQL1 is the string I use for selecting the records for the 2
week period and rst1 is the corresponding recordset
......strSQL2 is the string I use for selecting records for the second
week, rst 2 the recordset and so on for strSQL3 for week 3
Set dbs = currentdb
Set rst1 = dbs.OpenRecordset(strSQL1, dbOpenSnapshot)
If rst1.RecordCount = 0 Then
Call MsgBox("There is no data for this report@@ Please select new or
valid_
criteria", 16, "Message")
Cancel = True
Exit Sub
End If
Set rst2 = dbs.OpenRecordset(strSQL2, dbOpenSnapshot)
Set rst3 = dbs.OpenRecordset(strSQL3, dbOpenSnapshot)
If rst2.RecordCount = 0 or rst3.RecordCount = 0 Then
NoDataLabel.Visible = True 'Report header label
Call MsgBox("There is no data for the second week of this schedule.",
16,_
"Message")
End If
'Initialize SELECT statement.
MyRecordsource = strSQL
Set RecordSource property of Details Report.
Reports!rptBookingSchedule.RecordSource = MyRecordsource
DoCmd.Maximize
End Sub
The reporting of the basic data by week or 2 weeks works fine but not
the recordset criteria. Where am I going wrong?
Thanks
Gordon