Visual Basic 6.0 and Access
Hi,:D
I seem to be having problems with this code below, I have a Form made using Visual Basic 6.0 and a command button, inside the command button is:
Code:
Dim AccessApp As New Access.Application
Set AccessApp = CreateObject ("Access.Application") AccessApp.OpenCurrentDatabase ("C:\music.mdb") AccessApp.Visible = True AccessApp.DoCmd.OpenForm "frmmusic"
Now, what I'm trying to do is open a current database from this one command button, the database is stored on C:\ called music.mdb this seems to work but the problem i seem to be having is once Microsoft Access opens.. it closes straight away, any suggestions on how I can resolve this problem?
See Tools - Startup options
Are you doing either or both of these:
AccessApp.CloseCurrentDatabase
Set AccessApp = Nothing
I'm having a similar problem, but it seems to relate to whether or not my Access DB starts up with the switchboard form and/or the database window.
If it starts up with both of these already, and I'm opening a separate form (not the switchboard) from the VB code
I can still do the Set AccessApp = Nothing and everything works fine. When closing the form itself, then all of Access goes away.
It's all magic. I don't understand it.
In my case I wouldn't be surprised if something was corrupted.