Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to open access db, shuts down straight away

Status
Not open for further replies.

timotai

Technical User
Apr 13, 2002
119
0
0
GB
Hi all

This is really strange. I have the following code in an 'on click' sub to open up a form on an access database. But as soon as the database opens and loads the form it then shuts down. I can't see why and no other code is running and there are no macros on the database. If I open the database manually it is fine.

Code:
Dim X As Access.Application

Set X = New Access.Application
X.OpenCurrentDatabase ("C:\PaperWork.mdb")
X.Visible = True
X.DoCmd.RunCommand acCmdAppMaximize
X.DoCmd.OpenForm "Paperwork Log Queries", acNormal
X.DoCmd.Maximize

Im using VB6

Thanks

Tim
 
Hi,

Are you 100% that there is no code running behind the form in Access??

I tested the code you're using on a DB with a blank form and it worked fine for me.

Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Yeah. If I just open the form it works fine. If there was any other code it would run when I open the database myself. Also if I put the code on a module on another access database it opens up fine. It just seems to be from vb. Its very frustrating.
 
Have you tried using your code on another DB to see if it exclusively that DB or if the new DB exibits the same behaviour?

Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
I'll bet you have all this code inside your onclick handler. If so, the lifetime of x is limited to the time that the procedure is executing. You can fix this by declaring x at the module level, that is in the general declarations section. Then, put your instantiation, opendatabase and visible in the form's load event, and do your transient commands in the onclick event handler.

HTH

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top