-
Macro Help
I would like to create a macro in access which closes the database when a report is closed. Can anyone advise how i would go about doing this?
The reason behind this is that in my vb.net app i have a function to view access reports however once the report has been closed i dont want the user to be able to access anything else in the database therefore i will run the macro from my app to close the database.
Would appreciate any help greatly
-
Re: Macro Help
You can probably add VBA code to the class behind the report to do that but it may be better to use your vb.net automation code to execute the .Quit method of the Application (Access) object.
-
Re: Macro Help
Ok thanks. Heres my code for viewing a report:
Code:
Try
Dim oAccess As Access.Application
oAccess = New Access.Application
oAccess.Visible = True
Call oAccess.OpenCurrentDatabase(filepath:=FilePath, Exclusive:=False, bstrPassword:="A5B7C5D8E4")
With oAccess.DoCmd
.OpenReport(ReportName:=ReportName, View:=Access.AcView.acViewPreview)
.Maximize()
End With
oAccess = Nothing
Catch ex As Exception
MessageBox.Show("The following error occured: " & ex.Message)
End Try
How would i go about detecting when the report has closed in access so that i can call oAcces.Quit?
-
Re: Macro Help
Can anyone help with this? Last thing i need to complete application