|
-
May 10th, 2009, 02:57 PM
#1
Thread Starter
Addicted Member
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
-
May 10th, 2009, 03:11 PM
#2
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 11th, 2009, 01:49 PM
#3
Thread Starter
Addicted Member
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?
-
May 12th, 2009, 01:35 PM
#4
Thread Starter
Addicted Member
Re: Macro Help
Can anyone help with this? Last thing i need to complete application
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|