Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / March 2006

Tip: Looking for answers? Try searching our database.

Report Events to Trigger Update Query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Henry Stockbridge - 31 Mar 2006 15:18 GMT
Hi,

I need a way of bypassing the Report_Close procedure (or come up with
another event to handle the Update Query.)  Right now, if I set the
value of Report_NoData to Cancel=True, the Report_Close event fires,
and the message prompt is not applicable.

Here is the code:

Private Sub Report_Close()
  Dim varResponse As Variant
  Dim strSQL As String

   strSQL = "UPDATE tblOpenAccts INNER JOIN tblDFU_Hospitals ON " _
       & "tblOpenAccts.hosCustomerID = tblDFU_Hospitals.PrimInstID SET
" _
       & "tblOpenAccts.OpenedAccount = -1,tblOpenAccts.ModifiedDate =
Now(), " _
       & "tblOpenAccts.ModifiedBy = Environ('Username');"

   varResponse = MsgBox("These accounts are new." & vbCrLf & vbCrLf _
       & "Do you wish to flag these accounts as opened?", vbQuestion +
vbYesNo)

   If varResponse = vbYes Then
       ' Flag the accounts
       DoCmd.RunSQL strSQL
   End If

End Sub
'===========================
Private Sub Report_NoData(Cancel As Integer)
     MsgBox "No accounts to update"
             'Cancel = True
              'Need to close form without running Report_Close
procedure
End Sub
'=======================

Any help you can lend would be appreciated.

Henry
Tom van Stiphout - 31 Mar 2006 15:30 GMT
Seems to me you should set a flag in Report_NoData:
At the report module level:
Dim m_blnClosedByNoData as Boolean

In Report_NoData:
m_blnClosedByNoData = True

Test it in Report_Close:
if m_blnClosedByNoData then
 'Nothing to do
else
 'Update query goes here
end if

-Tom.

>Hi,
>
[quoted text clipped - 38 lines]
>
>Henry
Arno R - 31 Mar 2006 15:42 GMT
> Hi,
>
[quoted text clipped - 38 lines]
>
> Henry

You can't close the report without firing the close event...
(would be very weird if this was possible...)
Use another var to determine if you will ask for flagging the accounts.

In your reports module add:
Dim bolDoNotAsk as boolean

Private Sub Report_NoData(Cancel As Integer)
MsgBox "No accounts to update"
bolDoNotAsk=True
Cancel = True
End Sub

Private Sub Report_Close()
Dim varResponse As Variant
Dim strSQL As String
If bolDoNotAsk=True then exit sub

<your other code here>
End sub

Arno R
Henry Stockbridge - 31 Mar 2006 16:09 GMT
Thanks.  I'm all set now.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.