ACC2: Empty Recordset Report Hangs with Group KeepTogetherID: Q114549
|
Moderate: Requires basic macro, coding, and interoperability skills.
Microsoft Access stops while you are previewing a report and may mark
the database as corrupted. Running Repair Database on the database
eliminates the error message that states that the database is corrupted.
Microsoft Access can stop unexpectedly while you are previewing a report if
the report is based on an empty recordset and the group KeepTogether
property is set to With First Detail or Whole Group.
This is a known problem with "retreating" in Microsoft Access version 2.0
reports. "Retreating" refers to returning to an earlier report section in
order to determine where certain controls and sections are on a report, and
whether they will fit in a given space. Examples of retreating include:
To avoid this problem, test the report's underlying recordset to see if data is returned. If no data is returned, use the CancelEvent action to stop the report from processing. Two methods for avoiding the problem are described below.
Sub Report_Open (cancel As Integer)
If IsNull(DLookup("<AnyFieldInQuery>","<QueryName>")) Then
DoCmd CancelEvent
End If
End Sub
Sub Report_Open (Cancel As Integer)
Dim MyDb As Database, MyQuery As QueryDef, DataRecs As Recordset
Set MyDb = DBEngine.Workspaces(0).Databases(0)
Set MyQuery = MyDb.QueryDefs("QueryName")
MyQuery("Beginning Date:") = #1/1/96# ' or Forms!FormName![Control]
MyQuery("Ending Date:") = #1/3/96# ' or Forms!FormName![Control]
Set DataRecs = MyQuery.OpenRecordset()
If DataRecs.EOF Then DoCmd CancelEvent
DataRecs.Close
MyQuery.Close
End Sub
Microsoft has confirmed this to be a problem in Microsoft Access version 2.0. This problem no longer occurs in Microsoft Access version 7.0.
Customer ID
GroupHeader: Yes
KeepTogether: With First Detail
Order ID
GroupHeader: Yes
KeepTogether: With First Detail
Order Date
Ascending sort only
Report Name: A Test Report
View: Print Preview
Where: [Order Id] = 222
NWIND.MDB is corrupted or is not a database file. Attempt to
repair?
choose Yes.
Sub Report_Open (cancel As Integer)
If IsNull(DLookup("[Order Id]","Orders", "[Order Id] = 222")) Then
DoCmd CancelEvent
End If
End Sub
For more information about the Retreat event, search for "Retreat," and then "Retreat Event" using the Microsoft Access Help menu.
Additional query words: hang
Keywords : kbusage RptSort
Version : 2.0
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: April 3, 1999