Tab to Exit Application

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

I inserted a Tab Control on my form.

As intended, most of my tabs provide the user information about records.

However, I also want to create a tab (blank page) that allows to EXIT the
application when being clicked on.

Unfortunately, I cannot EXIT the application as envisioned. Here's what I
have done:

- Inserted a command button (anywhere in the form) and used the Wizard to
create "Exit Application". The code for this is listed below:

*************************************************
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click

DoCmd.Quit

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub
*************************************************

- Copied/pasted the above code into the OnClick function of the Tab/Page
called EXIT (then renamed the "Command3" to the name of the tab ("EXIT").
- Again, unfortunaly, this approach does not seem to work... the application
is not exited when I click on the Exit page.


I also tried to move a regular command button next to a Page. This,
however, does not work either since the Tab Control "sits ontop" of the
command button so I can't see the button.

Does anyone have a recommendation as to how I could fix the problem? Or
maybe there's another "smooth" solution that I couldn't think of... any
recommendation is appreciated!

Thanks,
Tom
 
Tom said:
I inserted a Tab Control on my form.

As intended, most of my tabs provide the user information about records.

However, I also want to create a tab (blank page) that allows to EXIT the
application when being clicked on.

Unfortunately, I cannot EXIT the application as envisioned. Here's what I
have done:

The Click event of a Tab Page is not what you think it is. It fires when
you click in the background of the current Tab Page. It does NOT fire when
you click on the small "tab" in order to change Tab Pages.

The event you need to use is the Change event of the entire TabControl.
Then you can test the Value property of the TabControl to determine what
page was selected.
 
Rick:

Thanks for your prompt reply!

Oh, I see... I wasn't aware of this.

I copied the "Exit Application" code into the OnChange event of the entire
tab control.

Now, however, I exit the application by simply switching from one data tab
to another (which makes sense)... that is not what I wanted though... I'm
sure you knew that.

Do you know if I can use something like an "IF Exit_Page" (or CASE)
statement before the "DoCmd.Quit"? Then, I guess the OnChange (and Exit
Application) would only be called if I indeed click on the Exit page?

Or did I misunderstood your approach? I'd appreciate any additional
pointers... thanks!

Tom
 
Tom said:
Rick:

Thanks for your prompt reply!

Oh, I see... I wasn't aware of this.

I copied the "Exit Application" code into the OnChange event of the entire
tab control.

Now, however, I exit the application by simply switching from one data tab
to another (which makes sense)... that is not what I wanted though... I'm
sure you knew that.

Do you know if I can use something like an "IF Exit_Page" (or CASE)
statement before the "DoCmd.Quit"? Then, I guess the OnChange (and Exit
Application) would only be called if I indeed click on the Exit page?

Or did I misunderstood your approach? I'd appreciate any additional
pointers... thanks!

Why don't you just put the button on the Exit page and then the only time
it can be used is when you are on that page?
 
Rick:

I though about that... it is an additional step though (Click Exit Page &
Click Exit Command button vs. Click only Exit Page).

I know this may seem tedious, but I believe that it would be less
"confusing" for the user.

If you have any suggestions as to how I could specify (Exit page IF) in the
OnChange event, I'd appreciate your feedback.

Thanks again,
Tom
 
Tom said:
Rick:

I though about that... it is an additional step though (Click Exit Page &
Click Exit Command button vs. Click only Exit Page).

I know this may seem tedious, but I believe that it would be less
"confusing" for the user.

If you have any suggestions as to how I could specify (Exit page IF) in the
OnChange event, I'd appreciate your feedback.

I misread your previous response. If the exit is occurring on every change
of the TabControl it is because you didn't include a test of the TabControl
Value as I suggested. If the TabIndex of the Exit page is 5 (for example)
then your code needs to be similar to...

If Me.TabControlName.Value = 5 Then...
DoCmd.Quit
End If
 
Back
Top