Fire event when tab selected?

WinDancer

Registered User.
Local time
Today, 01:40
Joined
Oct 29, 2004
Messages
290
I have a form "frmMyForm" with four tabs
"Page1"
"Page2"
"Page3"
"Page4"

there is a control on page4 named "txt35".

When the user selects the forth tab I want to fire an event, if txt35 is set to "Yes"

The form is not running the event...

Private Sub Page4_Click()

if forms!frmMyForm!Page4!txt35 =yes then
msgbox "Reading correctly"
end if

I don't think the form is self-aware of the tabs... help?

Thanks,
Dave
 
the form is aware of tabs

look at the events on the tab control

theres an onclick event, among others, which is probably the one you want

just test the checkbox in that event
 
try:
If forms.frmMyForm.txt35 =yes then

your controls are owned by your form, not by your page.
 
if its a text box the n you need (without the explicit references)

if txt35 = "Yes" then etc

if its a check box you need

if txt35 = true then etc

or better still just

if txt35 then etc

------
but you dont specify what to do if its false, so perhaps it is working, just not doing anything
 
The OnClick for a page means clicking on the page itself, not the tab for the page! To do what you want you need to use the Change event, and since the index for tabbed pages is Zero indexed, the value for Page4 is 3. So the code to identify when the tab for Page4 is "clicked" is:

Code:
Private Sub YourTabbedControlName_Change()

If Me.YourTabbedControlName.Value = 3 
   'Your code here
End If

End Sub

BTW, this is one of those quirky Access things where the Change event for the control is only available in the dropdown box (the one that says (General)) in the code window; it's not available in the Properties Box.

Then you need to use Gemma's code, depending, as stated, on whether txt35 is actually a textbox or a checkbox.
 
BTW, this is one of those quirky Access things where the Change event for the control is only available in the dropdown box (the one that says (General)) in the code window; it's not available in the Properties Box.

Missinglinq- Thanks for the help- it took about 10 minutes to bumble around and find the correct spot and correct code and everything is working perfectly now.

This board is the best!

Thanks,
Dave
 

Users who are viewing this thread

Back
Top Bottom