ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Access form from Excel (https://www.excelbanter.com/excel-programming/421749-access-form-excel.html)

Emiliano

Access form from Excel
 
Hello,

I am using the OpenCurrentDatabase method with the following code:

Sub Pref(seeit As Boolean, openit As Boolean)

Dim PrefPath As String

'Path of pref.mdb
PrefPath = ThisWorkbook.Path & "\pref.mdb"

'Open Access and make it visible when seeit=true
Set oApp = CreateObject("Access.Application")
oApp.Visible = seeit

'open pref.mdb
oApp.OpenCurrentDatabase PrefPath

'open the following query
oApp.DoCmd.OpenQuery "qAppendFax"
oApp.DoCmd.OpenQuery "qDeleteFax"
oApp.DoCmd.OpenQuery "qAppendTeor"
oApp.DoCmd.OpenQuery "qdeleteTeor"
'open the fax form if openit=true
If openit Then
oApp.DoCmd.OpenForm "fax"
End If
'closes db
oApp.CloseCurrentDatabase
Set oApp = Nothing
End Sub

the boolean argument seeit allows to show or to hide the Access window
while openit allows to skip the opening of the "fax" form.
My issue is that when the two arguments are both set on true Access
don't stays open on the form but closes immediately. This event don't
happen if the two statements

oApp.CloseCurrentDatabase
Set oApp = Nothing

are omitted.

Are these two statements necessary, or I get the same result closing
the Access window manually?

Moreover is it possible to get the Access window open maximized?

Emiliano




All times are GMT +1. The time now is 12:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com