By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,658 Members | 1,134 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,658 IT Pros & Developers. It's quick & easy.

Click event of a tab control page not firing

P: n/a
I have some funky form/event behavior.

Access 97. Split frontend/backend, using Access security. I have the
same behavior (or lack of behavior) for the pag_Click() event of two
separate pages on different menu forms. Details:

frmTRNMenu is the main menu of the application. It uses tabbed pages
to logically separate menu items. The last tab on the list is
different - it has an image and then "O&M". Clicking on this last
page will IDEALLY hide the main menu and open the O&M menu. I have
directed the program, for the "On Click" event, to run my specific
"SwitchToOMRMenu" event, to achieve the ideal goal. The code works.
Or, at least, it did.

frmOMRMenu is the "O&M" menu. It has a large set of its own
options--too many to include on the main menu. It also has, as the
last page in the tab control, an "On Click" event which calls the
"SwitchToTRNMenu" subroutine. Guess what that one does...

Oh, and if someone manages to get to the page without using the mouse,
meaning without using "clicks", I have set up a command button that
says "Click Here to go to the O&M Records menu". So I have that angle
covered as well.

Now for the problem. The problem is that the click event of the page
is simply not firing. I have set a breakpoint on the beginning of the
event itself,
i.e. (*BREAKPT HERE*)Private Sub pagOMRMenuLink_Click()

No dice. Clicking on the page does nothing.
Now. This used to work. I don't know what I did, but I apparently
broke the functionality. I will tell you what I have already done to
(unsuccessfully) fix this:

1. I have already tried to delete the event and re-add it. Delete it
from code, save, go to the page's Properties box, click on the "On
Click" event [...] button, and generate the event again. No dice.
2. I have run /decompile, closed the db, re-opened the db, recompiled
everything, compacted, and re-entered the database. No dice.
3. I have combined #1 and #2 - deleted the event,
decompile/recompiled, then re-added the event.
I have no idea where the problem is. Just in case I'm doing something
insanely awful, I'll post my "switch" subroutines. Feel free to
critique them. Also, if there is a better suggestion as to how to
switch menus, feel free to critique my form design. I'm tough.
Pete
Attached code below, from BOTH form modules (will be long):

'frmTRNMenu code module
Option Compare Database
Option Explicit

Private m_fIsSwitching As Boolean
Private Sub cmdOMRFocusGrabber_Click()
SwitchToOMRMenu
End Sub

Private Sub Form_Open(Cancel As Integer)
'initialize variable to false, so we know it defaults to false
m_fIsSwitching = False
End Sub


Private Sub SwitchToOMRMenu()
On Error GoTo Sub_Error
If m_fIsSwitching = True Then Exit Sub

m_fIsSwitching = True

DoCmd.Echo False

If IsLoaded("frmOMRMenu") Then
Forms!frmOMRMenu.Visible = True
Else
DoCmd.OpenForm "frmOMRMenu"
End If

DoCmd.SelectObject acForm, "frmOMRMenu"

Forms!frmTRNMenu!tabMain.Pages!pag1.SetFocus
Forms!frmTRNMenu.Visible = False

m_fIsSwitching = False

DoCmd.Echo True

Sub_Exit:

Exit Sub

Sub_Error:
DoCmd.Echo True
MsgBox Err.Description
Resume Sub_Exit
End Sub
Private Sub pagOMRMenuLink_Click()
SwitchToOMRMenu
End Sub

'----------------------------------------------------------
'----------------------------------------------------------
'frmOMRMenu code module
'----------------------------------------------------------
'----------------------------------------------------------
Option Compare Database
Option Explicit
Private m_fIsSwitching As Boolean
Private Sub Form_Open(Cancel As Integer)
'initialize variable to false, so we know it defaults to false
m_fIsSwitching = False
End Sub

Private Sub SwitchToTRNMenu()
On Error GoTo Sub_Error
If m_fIsSwitching = True Then Exit Sub

m_fIsSwitching = True

DoCmd.Echo False

If IsLoaded("frmTRNMenu") Then
Forms!frmTRNMenu.Visible = True
Else
DoCmd.OpenForm "frmTRNMenu"
End If

DoCmd.SelectObject acForm, "frmTRNMenu"

Forms!frmOMRMenu!tabMain.Pages!pag1.SetFocus
Forms!frmOMRMenu.Visible = False

m_fIsSwitching = False

DoCmd.Echo True

Sub_Exit:

Exit Sub

Sub_Error:
DoCmd.Echo True
MsgBox Err.Description
Resume Sub_Exit
End Sub
Private Sub pagLast_Click()
SwitchToTRNMenu
End Sub
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Pete" <ps********@zombieworld.com> wrote in message
news:98**************************@posting.google.c om...
I have some funky form/event behavior.

Access 97. Split frontend/backend, using Access security. I have the
same behavior (or lack of behavior) for the pag_Click() event of two
separate pages on different menu forms. Details:

frmTRNMenu is the main menu of the application. It uses tabbed pages
to logically separate menu items. The last tab on the list is
different - it has an image and then "O&M". Clicking on this last
page will IDEALLY hide the main menu and open the O&M menu. I have
directed the program, for the "On Click" event, to run my specific
"SwitchToOMRMenu" event, to achieve the ideal goal. The code works.
Or, at least, it did.

frmOMRMenu is the "O&M" menu. It has a large set of its own
options--too many to include on the main menu. It also has, as the
last page in the tab control, an "On Click" event which calls the
"SwitchToTRNMenu" subroutine. Guess what that one does...

Oh, and if someone manages to get to the page without using the mouse,
meaning without using "clicks", I have set up a command button that
says "Click Here to go to the O&M Records menu". So I have that angle
covered as well.

Now for the problem. The problem is that the click event of the page
is simply not firing. I have set a breakpoint on the beginning of the
event itself,
i.e. (*BREAKPT HERE*)Private Sub pagOMRMenuLink_Click()


Where exactly are you clicking? It may seem counter-intuitive, but the
"tab" that you click on to change Tab Pages is not considered part of the
Tab Page so it doesn't fire the page's Click event. That fires when you
click on a blank area of the page *after* you have made that page the one
"on top".

If you want an event that fires when you change Tab Pages then you have to
use the Change event of the TabControl. To make that code "page specific"
you test the value property of the TabControl in the change event to
determine which page was just selected and run your code accordingly.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 12 '05 #2

P: n/a
> Where exactly are you clicking? It may seem counter-intuitive, but the
"tab" that you click on to change Tab Pages is not considered part of the
Tab Page so it doesn't fire the page's Click event. That fires when you
click on a blank area of the page *after* you have made that page the one
"on top".

If you want an event that fires when you change Tab Pages then you have to
use the Change event of the TabControl. To make that code "page specific"
you test the value property of the TabControl in the change event to
determine which page was just selected and run your code accordingly.


That's exactly what I needed to know. What happened is this:

1. I set the "click" event of the (then-empty) page. It worked as I
expected--when I clicked on the page "tab" itself, the event would
fire.
2. I added the button to the page. The event quit firing.
3. Curious as to the odd behavior, I went ahead and added a similar
button to the other page on the other menu. Now that that page was no
longer empty, that event stopped firing as well.

Now I know. Use the "On Change" event of the tab control itself.
Thanks.
Pete
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.