R
RGG
I have an access report (Rpt A) that, when closed, runs an update query (Qry
B) to change the values in the query upon which Rpt A is based (Qry A). This
uses the "on close" event procedure of Rpt A to run Qry B via a form (Frm A).
I have added a sub report to Rpt A to give some additional information but
when Rpt A is closed it now asks for the query criteria several times before
closing. To get over this problem I created another form (Frm B) to provide
the criteria for Qry A and this works just fine. This process added another
"on close" event to Rpt A that closes Frm B that provides the criteria data
for the query.
However now the update query (Qry B) runs when Rpt A is closed but cannot
find any records to update, presumably because the form supplying the
criteria to the query (Frm B) has been closed by the Rpt A "on close" event.
Presumably this would leave Qry A with no records to update
The code for Rpt A is as follows:
Private Sub Report_Close()
DoCmd.Close acForm, "frm Staff Initial"
DoCmd.OpenForm "frm Run Wages Update"
End Sub
Private Sub Report_Open(Cancel As Integer)
' Set public variable to true to indicate that the report
' is in the Open event
bInReportOpenEvent = True
' Open Sales By Category Dialog
DoCmd.OpenForm "frm Staff Initial", , , , , acDialog
' Cancel Report if User Clicked the Cancel Button
If IsLoaded("frm Staff Initial") = False Then Cancel = True
' Set public variable to false to indicate that the
' Open event is completed
bInReportOpenEvent = False
End Sub
So how can I get the update query (Qry B) to update the records in qry A?
I assume that there must be a way of controlling the order of the on close
events to avoid Qry A being deprived of criteria before the update query has
a chance to work.
Any help would be greatly appreciated.
B) to change the values in the query upon which Rpt A is based (Qry A). This
uses the "on close" event procedure of Rpt A to run Qry B via a form (Frm A).
I have added a sub report to Rpt A to give some additional information but
when Rpt A is closed it now asks for the query criteria several times before
closing. To get over this problem I created another form (Frm B) to provide
the criteria for Qry A and this works just fine. This process added another
"on close" event to Rpt A that closes Frm B that provides the criteria data
for the query.
However now the update query (Qry B) runs when Rpt A is closed but cannot
find any records to update, presumably because the form supplying the
criteria to the query (Frm B) has been closed by the Rpt A "on close" event.
Presumably this would leave Qry A with no records to update
The code for Rpt A is as follows:
Private Sub Report_Close()
DoCmd.Close acForm, "frm Staff Initial"
DoCmd.OpenForm "frm Run Wages Update"
End Sub
Private Sub Report_Open(Cancel As Integer)
' Set public variable to true to indicate that the report
' is in the Open event
bInReportOpenEvent = True
' Open Sales By Category Dialog
DoCmd.OpenForm "frm Staff Initial", , , , , acDialog
' Cancel Report if User Clicked the Cancel Button
If IsLoaded("frm Staff Initial") = False Then Cancel = True
' Set public variable to false to indicate that the
' Open event is completed
bInReportOpenEvent = False
End Sub
So how can I get the update query (Qry B) to update the records in qry A?
I assume that there must be a way of controlling the order of the on close
events to avoid Qry A being deprived of criteria before the update query has
a chance to work.
Any help would be greatly appreciated.