Referencing the active page of a tab control

S

str8trini

I have command buttons set to open a popup form on each of three pages on a
tab control. Is there a way to identify the active page so that I can open
the popup form with a different record source depending on the active page?
I thought I could simply use the IsLoaded property but that does not apply to
pages or subforms. It is important to know the active page because the
record source contains a parameter that references information populated on
the active page. Thank you in advance for taking the time to reder some
assistance.
 
S

Stuart McCall

str8trini said:
I have command buttons set to open a popup form on each of three pages on a
tab control. Is there a way to identify the active page so that I can
open
the popup form with a different record source depending on the active
page?
I thought I could simply use the IsLoaded property but that does not apply
to
pages or subforms. It is important to know the active page because the
record source contains a parameter that references information populated
on
the active page. Thank you in advance for taking the time to reder some
assistance.

Dim PageNumber As Long

PageNumber = Me.TabControl.Value

The pages of a tab control are numbered from 0, left to right, so if
PageNumber = 2, then the third tab is currently active.
 
S

str8trini

I receive a compile error message "Method or data member not found" when I
use the .value property.

Also will I be able to enter into the OnOpen event procedure of the popup
form that If the value of the page number is X then use a specific record
source?
 
S

Stuart McCall

str8trini said:
I receive a compile error message "Method or data member not found" when I
use the .value property.

I think you'd better post your code. TabControlName.Value should not cause a
compile error.
Also will I be able to enter into the OnOpen event procedure of the popup
form that If the value of the page number is X then use a specific record
source?

I don't see why not. If the form containing the tab control is called Form1
and the tab control is called Tab1, the syntax would be:

If Forms!Form1.Tab1.Value = X Then
Me.RecordSource = <whatever>
End If
 
D

Dale Fye

Also will I be able to enter into the OnOpen event procedure of the popup
form that If the value of the page number is X then use a specific record
source?

Several ways to approach this.

1. Set the recordsource property of your Popup form to "". Then, when you
open your popup form, you can pass it the name of the recordsource, as an
OpenArgs parameter, and in the forms Open event, set the RecordSource
property = to the form.openargs property.

2. The other way would also involve setting the default recordsource
property of the popup to "", then, in the Form_Open event, refer to the
calling forms tab value to set your Recordsource. Something like:

Private Sub Form_Open()

Select Case Forms("MainFormName").tabControlName.Value
Case 0
me.recordsource = "query1"
Case 1
me.recordsource = "query2"
End select

End sub

HTH
Dale
--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



:> Also will I be able to enter into the OnOpen event
procedure of the popup
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top