scottfarcus
Registered User.
- Local time
- Today, 20:25
- Joined
- Oct 15, 2001
- Messages
- 182
Can anyone help with some Access automation? Here is my code...
' Initialize string to database path.
Const strPath = "C:\My Documents\"
strDB = strPath & "Test.mdb"
' Create new instance of Microsoft Access.
Set appAccess = CreateObject("Access.Application")
' Open database in Microsoft Access window.
appAccess.OpenCurrentDatabase strDB
appAccess.Visible = True
appAccess.DoCmd.OpenForm "FormMain"
Now, it opens the database fine, but the db immediately closes for some reason. I have read somewhere that this code should be in a module (and you should open a form), otherwise, the Access object will fall out of scope and be closed. I placed this in a module, but it still closes.
Any takers?
' Initialize string to database path.
Const strPath = "C:\My Documents\"
strDB = strPath & "Test.mdb"
' Create new instance of Microsoft Access.
Set appAccess = CreateObject("Access.Application")
' Open database in Microsoft Access window.
appAccess.OpenCurrentDatabase strDB
appAccess.Visible = True
appAccess.DoCmd.OpenForm "FormMain"
Now, it opens the database fine, but the db immediately closes for some reason. I have read somewhere that this code should be in a module (and you should open a form), otherwise, the Access object will fall out of scope and be closed. I placed this in a module, but it still closes.
Any takers?