Problems openingusing VBA Access from Excel

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
 
D

Douglas J. Steele

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
 
J

Jan Kronsell

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top