PC Review


Reply
Thread Tools Rate Thread

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

 
 
Chris K
Guest
Posts: n/a
 
      18th Aug 2010
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


 
Reply With Quote
 
 
 
 
David W. Fenton
Guest
Posts: n/a
 
      19th Aug 2010
"Chris K" <(E-Mail Removed)> wrote in
news:S2Xao.61349$GQ5.20691@hurricane:

> 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.

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/
 
Reply With Quote
 
Chris K
Guest
Posts: n/a
 
      21st Aug 2010


"David W. Fenton" <(E-Mail Removed)> wrote in message
news:Xns9DD9868C16650f99a49ed1d0c49c5bbb2@74.209.136.88...
> "Chris K" <(E-Mail Removed)> wrote in
> news:S2Xao.61349$GQ5.20691@hurricane:
>
>> 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.



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

 
Reply With Quote
 
David W. Fenton
Guest
Posts: n/a
 
      21st Aug 2010
"Chris K" <(E-Mail Removed)> wrote in
news9Ebo.52146$7E.8336@hurricane:

> 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.

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Completely Exit Excel Macro =?Utf-8?B?Um9i?= Microsoft Excel Misc 3 13th Jul 2007 12:56 PM
outlook doesn't completely exit =?Utf-8?B?bG9iaWxs?= Microsoft Outlook Discussion 0 8th Apr 2005 04:59 PM
Outlook 2003 Will Not Exit Completely VR Microsoft Outlook 5 6th Aug 2004 06:18 PM
Outlook 2002 does not exit completely Leef Microsoft Outlook Discussion 7 27th Jul 2004 11:01 PM
Outlook doesn't exit completely PamT Microsoft Outlook Discussion 0 15th Jun 2004 03:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:00 AM.