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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi-Tabbed Form - On click - Logout 4

Status
Not open for further replies.
Mar 2, 2005
171
US
I have a multi-tabbed form and the last tab is for the end-user to logout of the database by clicking on the tab.

What modifications do I need to make so the following code will work?

Private Sub Page8_Click()
On Error GoTo Err_cmdExit_Click
DoCmd.Quit
Exit_Page8_Click:
Exit Sub
Err_Page8Exit_Click:
MsgBox Err.Description
Resume Exit_cmdExit_Click
End Sub

 
make so the following code will work
What is not working ?
Computer crash ? Error message ? Unexpected behaviour ? ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The only thing I see is your On Error statement is not correct:
Code:
On Error GoTo Err_cmdExit_Click
should be:
Code:
On Error GoTo Err_[red]Page8[/red]Exit_Click
HTH,

Ken S.
 
Good catch Eupher !
Same thing for the Resume instruction:
Resume Exit_[!]Page8[/!]_Click

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Ha! Good catch for you, also, PHV. I missed the one in the Resume statement...

Ken S.
 
Made the suggested changes but upon clicking on the tab titled "Logout", I am not logged out of the database!

What am I missing here?

 
And what about simply this ?
Private Sub Page8_Click()
Application.Quit
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Using the following code that is just not working!

Private Sub Page8_Click()
'On Error GoTo Err_Page8Exit_Click
Application.Quit

'Exit_Page8_Click:
' Exit Sub
'Err_Page8Exit_Click:
' MsgBox Err.Description
' Resume Exit_Page8_Click
End Sub


 
Okay, here's what seems to be happening...

Clicking on the tab selector does not invoke the tab page's Click event - once the tab page has been selected, clicking anywhere in the control area of the tab page (i.e. not the tab selector) fires the click event and your code will work.

But that's obviously not what you are after. So far I have not been able to determine if the action of selecting a tab page is an event on which you can hang VBA code. Seems like it must be, but I haven't found it yet. But here's a workaround...

When you select a tab page, focus automatically moves to the control that is first in the tab order on that tab page. So, just place a textbox on your tab page, and put the DoCmd.Quit command in the textbox's GotFocus event.

This seems like a kludge to me, but I haven't been able to figure a better solution...

HTH,

Ken S.
 
Are you talking about a tab control? Here is the common solution, forget any work arounds. This fires on the tab or anywhere else.

1) Use the tab controls "change" event
2) The value of the tab control is the index of the selected page.
3) So do something like.

Private Sub TabCtl0_Change()
If TabCtl0.Pages(TabCtl0.Value).Name = "your page name" Then
your code here
End If
End Sub

Or simply

Private Sub TabCtl0_Change()
If TabCtl0 = (your page index) Then
your code here
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top