Problems openingusing VBA Access from Excel

  • Thread starter Thread starter Jan Kr
  • Start date Start date
J

Jan Kr

I try to open an Access database from Excel, using the following code

Sub OpenDatabase()

strdb = "c:\demo.mdb"
Set appaccess = CreateObject("Access.Application")
appaccess.Visible = True
appaccess.OpenCurrentDatabase strdb
appaccess.DoCmd.OpenForm "frmsysteminformation"
Set appaccess = Nothing
End Sub

It works Ok, and dispalys the form. My problem is, I do not want to display
a form, only the database window. If I leave out the line

appaccess.DoCmd.OpenForm "frmsysteminformation"

or ad

appaccess.DoCmd.Close

the database opens, but closes dwon immediately. Is there any way to start
Access, open the database, and display the database window?

Jan
 
I believe the problem is that you're setting appaccess to Nothing at the end
of the routine. That closes it.

One thing you could try doing is opening your form as hidden.

appaccess.DoCmd.OpenForm "frmsysteminformation", , , , , 1

or

appaccess.DoCmd.OpenForm FormName:="frmsysteminformation", WindowMode:= 1
 
Removingthe Set appaccess = nothing makes no difference. But opening the
form hidden does, solve my problem. Then of course another problem occurs.
Some of my databases do not have any forma in them. So they wont display at
all.

Jan
 
Back
Top