How Do I exit/stop/end execution completely???

C

Chris K

This is the opening code in my (start up) form

Private Sub Form_Load()

If Date - DateValue(Version.Caption) > 5 Then Quit


I've tried Quit, Docmd.Quit, End, Exit and in all cases it continues to
execute code grrrrrrrrrrrr until it finds an error in Form_Current procedure
and I dont want it to go that far - I just want it to stop, which I've also
tried by the way

btw, How can I switch errors On?

I understand that Resume signifies where/when the execution process can
continue but does this also switch errors back on? - it's not specifically
mentioned in the help files

I cant help but feel that errors are being suppressed (Resume Next style)
until it literally gets bogged down it cant possibly run
 
D

David W. Fenton

This is the opening code in my (start up) form

Private Sub Form_Load()

If Date - DateValue(Version.Caption) > 5 Then Quit

Application.Quit closes the application, if that's what you want to
do.
I've tried Quit, Docmd.Quit, End, Exit and in all cases it
continues to execute code grrrrrrrrrrrr until it finds an error in
Form_Current procedure and I dont want it to go that far - I just
want it to stop, which I've also tried by the way

btw, How can I switch errors On?

What do you mean by that?

There is an interaction between what's in your code and the settings
in the VBE's Options page.
I understand that Resume signifies where/when the execution
process can continue but does this also switch errors back on? -
it's not specifically mentioned in the help files

On Error GoTo errHandler
- passes controller to a label when there's an error

On Error GoTo 0
- turns off any defined error statement, and returns to the state
where there is no error handler defined (i.e., you'll get the
default error)

On Error Resume Next
- ignore any error following and move on to the next line

In general, On Error Resume Next should not be used with more than
one line at a time, and should always be followed by an On Error
GoTo statement to restore either your local error handler or VBA's
default error handling.

I avoid On Error Resume Next and instead prefer to ignore an
expected error in the error handler. The reason is that On Error
Resume Next will ignore all errors, even the ones you're not
expecting.
I cant help but feel that errors are being suppressed (Resume Next
style) until it literally gets bogged down it cant possibly run

It's not clear from your description of the problem that error
handling has anything to do with your problem. You're just not using
the right command to quit the app if your condition is met.
 
C

Chris K

David W. Fenton said:
Application.Quit closes the application, if that's what you want to
do.


What do you mean by that?

There is an interaction between what's in your code and the settings
in the VBE's Options page.


On Error GoTo errHandler
- passes controller to a label when there's an error

On Error GoTo 0
- turns off any defined error statement, and returns to the state
where there is no error handler defined (i.e., you'll get the
default error)

On Error Resume Next
- ignore any error following and move on to the next line

In general, On Error Resume Next should not be used with more than
one line at a time, and should always be followed by an On Error
GoTo statement to restore either your local error handler or VBA's
default error handling.

I avoid On Error Resume Next and instead prefer to ignore an
expected error in the error handler. The reason is that On Error
Resume Next will ignore all errors, even the ones you're not
expecting.


It's not clear from your description of the problem that error
handling has anything to do with your problem. You're just not using
the right command to quit the app if your condition is met.


I have tried:

Private Sub Form_Load()

Application.Quit

but it totally ignores the instruction and crashes half way through 'Form
Current' event (errors out because the form hasn't loaded)

I've spent days trying to halt the program and I have finally concluded that
it is absolutely impossible to halt VB *in it's tracks* on Access Form

As a result I can't bring the program to a dignified end and decided instead
just let it run out of steam and railroad the whole system

Thanks anyway
 
D

David W. Fenton

I have tried:

Private Sub Form_Load()

Application.Quit

but it totally ignores the instruction and crashes half way
through 'Form Current' event (errors out because the form hasn't
loaded)

I've spent days trying to halt the program and I have finally
concluded that it is absolutely impossible to halt VB *in it's
tracks* on Access Form

Where are you getting the value you are checking in the OnLoad
event? You might try moving it to the OnOpen event, which you can
cancel, and then that might take care of the problem.
 

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