On Open Event Procedure Problem

MarkL

Registered User.
Local time
Today, 01:22
Joined
Dec 16, 2009
Messages
12
Hi,

I am having a problem with an On Open Event Procedure. I have a main form - fMainForm1 that loads on Startup with a subform - frmHelpAbout, which is designed to display certain information and check to see if certain Tables are present. If the Tables are present, after a short time delay a MsgBox appears to load the Log In SubForm, and everything is working OK if the various Tables are found. If a Table is not found, a MsgBox appears warning the table data is not found. When click OK, supposed to Quit the application. However, what happens if a Table is not found is the MsgBox appears but when click OK, get another MsgBox with error stating Quit is not available with End or Debug. If click End, then fMainForm1 loads without frmHelpAbout. If click Debug, goes into VB Debug with the DoCmd.Quit highlighted. Below is the On Open Event Procedure coding for the subform I am using. Hope someone can help me figure out why it will not Quit. Thanks!

****Coding****

Private Sub Form_Open(Cancel As Integer)
On Error GoTo CloseProgramAndExit

DoCmd.Maximize
Forms!fMainForm1.Caption = "About Program & Verification"
Me.lblVerifyingDataFiles.Caption = "Checking Tables . . ."
' Check ConfigTable
If Not TableExists("ConfigTable") Then
MsgBox "Database will close. Contact Programmers.", vbCritical & vbOKOnly, "COMPANY CONFIGURATION NOT FOUND!"
GoTo CloseProgramAndExit
End If
' Check LicenseTable
If Not TableExists("LicenseTable") Then
MsgBox "Database will close. Contact Programmers.", vbCritical & vbOKOnly, "LICENSE NOT FOUND!"
GoTo CloseProgramAndExit
End If
' Check Administrator Log In Table
If Not TableExists("tblLogInAdmin") Then
MsgBox "Database will close. Contact Programmers.", vbCritical & vbOKOnly, "ADMINISTRATOR DATA NOT FOUND!"
GoTo CloseProgramAndExit
End If
' Check Employees/Users Log In Table
If Not TableExists("tblEmployees") Then
MsgBox "Database will close. Contact Programmers.", vbCritical & vbOKOnly, "EMPLOYEES/USERS DATA NOT FOUND!"
GoTo CloseProgramAndExit
End If
' Check Date Table
If Not TableExists("DateTable") Then
MsgBox "Database will close. Contact Programmers.", vbCritical & vbOKOnly, "DATE DATA NOT FOUND!"
GoTo CloseProgramAndExit
End If
' Check Month Table
If Not TableExists("MonthTable") Then
MsgBox "Database will close. Contact Programmers.", vbCritical & vbOKOnly, "MONTH DATA NOT FOUND!"
GoTo CloseProgramAndExit
End If
' Check Form Usage Log Table
If Not TableExists("tblLogDoc") Then
MsgBox "Database will close. Contact Programmers.", vbCritical & vbOKOnly, "FORM USAGE DATA NOT FOUND!"
GoTo CloseProgramAndExit
End If
' Check Legal Practice Table
If Not TableExists("LegalPracticeTable") Then
MsgBox "Database will close. Contact Programmers.", vbCritical & vbOKOnly, "LEGAL PRACTICE DATA NOT FOUND!"
GoTo CloseProgramAndExit
End If

Exit_and_End:
Exit Sub

CloseProgramAndExit:
DoCmd.Quit

End Sub
 
What if you try application.quit instead of docmd.quit. do you still receive the error?
 
What if you try application.quit instead of docmd.quit. do you still receive the error?

Yes, I receive same error, but application does quit (as opposed to not quiting with DoCmd.Quit) with same MsgBox still on screen:

Run-time error "2046":

The command or action 'Quit' is not available now.

with same buttons available End and Debug active (but Continue and Help buttons grayed out and not active as with DoCmd.Quit).

How do I have the application quit as it does, but not get the Run-time error box?
 
Last edited:
What version of access are you using?
 
I dont have a machine handy to check on 2000 but i can tell you your code works in 2007 (without the tableexits check)

My only other suggestion would be to try to close the forms before you close the application??

Edit: Not sure if you've seen this or if it applies to your situation

http://support.microsoft.com/kb/244695
 
Last edited:
I dont have a machine handy to check on 2000 but i can tell you your code works in 2007 (without the tableexits check)

My only other suggestion would be to try to close the forms before you close the application??

Edit: Not sure if you've seen this or if it applies to your situation

http://support.microsoft.com/kb/244695

Thanks. I put in to close the Modules and Forms (see coding below, although not sure option acQuitSaveNone does anything because same problem occurs with and without the option). It did not work to prevent the Message Box about Quit not being available although the application does quit. I read the above article, but not sure how to adapt to my situation or whether it would work if adapted.

DoCmd.Close acModule, "ajbVersion"
DoCmd.Close acModule, "modTableCheck"
DoCmd.Close acForm, "frmHelpAbout"
DoCmd.Close acForm, "fMainForm1"
Application.Quit acQuitSaveNone

Any other suggestions, or anyone else have any suggestions/solutions?
 
Have you tried to run the same code from a command button instead of the form open event?

I see at the bottom of the microsoft article, linked by rainman, it is mentioned that the db window needs to load... as you state "fMainForm1 that loads on Startup" I am wondering if this would not be the issue?

try run it from a button and if that works then a work around can be devised...
 
Have you tried to run the same code from a command button instead of the form open event?

I see at the bottom of the microsoft article, linked by rainman, it is mentioned that the db window needs to load... as you state "fMainForm1 that loads on Startup" I am wondering if this would not be the issue?

try run it from a button and if that works then a work around can be devised...

Hi dcb,

Thanks, yes - works using a command button. I am attaching two files, #1 is the original coding used that causes problems, and #2 is the coding using the command button as you suggested. Not sure why #2 works and #1 does not work (??? - any work around?).

Mark
 

Attachments

Users who are viewing this thread

Back
Top Bottom