Active Page on Tab-Control

MarionD

Registered User.
Local time
Today, 22:50
Joined
Oct 10, 2000
Messages
425
Hallo all,

I need some help again!

I have main form with tab control with 4 pages.
On each t
Page I have a sub form with different data but all bound to the main form by a unique ID.
On each Page I have a Report Preview Button.

I have ONE Report design as the Info in the Sub-forms can all be linked to the same ID.
I use a recordset clone of the sub form from which the Report preview is clicked to fill a local table which is the source of the report.

NOW ALL I want to do is fill an unbound control on the report with the Caption of the Page it is printed from! (Active Page on Tab Control ?)I have tried the following code, but as the form is opened before the value for the unbound control is set, it doesn’t display unless I set the page margins or something!

stDocName = "TerminKalender_RPT"
DoCmd.OpenReport stDocName, acViewPreview
Reports!terminkalender_rpt!reptitle = Me.RUHE.Caption
Forms![termin_kalender_frm].Visible = False

Is there perhaps a way of finding out on the ON OPEN of the report, which is the active tab-control page and then filling in the unbound control with the caption?

Thanks a lot
Marion
 
Thank you - have found the answer in the Archives!
 
where is it in the archive ?

I need to know the current active tab page so that I can enable a specific button in the form. (if the user opens the Letter tab, the delete letter button will become active)

any idea ?
 
Hi there,
Sory cant remember exactly where I found it but this is how I did it maybe it will help:
I used a select case :
x = Forms!frm_TerminKalender!Register - this returns a the number of the tab control then:

Select Case x
Case Is = 0
Set insrecs = Forms![frm_TerminKalender]![frm_TerminKalender_Ruhe].Form.RecordsetClone
stDocname = "Rpt_TerminKalender"
Case Is = 1
Set insrecs = Forms![frm_TerminKalender]![frm_TerminKalender_Nutz].Form.RecordsetClone
stDocname = "Rpt_TerminKalender"
Case Is = 2
Set insrecs = Forms![frm_TerminKalender]![frm_TerminKalender_Frist_1].Form.RecordsetClone
stDocname = "Rpt_TerminKalenderMangel"
Case Is = 3
Set insrecs = Forms![frm_TerminKalender]![frm_TerminKalender_Frist_2].Form.RecordsetClone
stDocname = "Rpt_TerminKalenderMangel"
Case Is = 4
Set insrecs = Forms![frm_TerminKalender]![frm_TerminKalender_Sperre].Form.RecordsetClone
stDocname = "Rpt_TerminKalender"
End Select

I did the same in setting the unbound field:

Private Sub Berichtskopf_Print(Cancel As Integer, PrintCount As Integer)
Dim x
x = Forms!frm_TerminKalender!Register
If x = 0 Then Me!reptitle = Forms!frm_TerminKalender!Ruhe.Caption
If x = 1 Then Me.reptitle = Forms!frm_TerminKalender!Nutz.Caption
If x = 2 Then Me.reptitle = Forms!frm_TerminKalender!Frist1.Caption
If x = 3 Then Me.reptitle = Forms!frm_TerminKalender!frist2.Caption
If x = 4 Then Me.reptitle = Forms!frm_TerminKalender!sperre.Caption

Hope this helps
Marion
 
The quick way to do this (since you can wind up moving or inserting tab pages and then if you use the index value you would have to re-code to fix the changes:

Put this in the Tab Control's On CHANGE event:
Code:
Select Case Me.YourTabControlName.Pages(Me.YourTabControlName.Value).Name
   Case "WhateverTheNameIsHere
       ...put code here to do if the tab selected is "WhateverTheNameIsHere"
   Case "AnotherTabNameHere"
       ...put code here to do something if the tab selected is named "AnotherTabNameHere
End Select
 
I like to expose the active tab page as a custom property of the form...
Code:
Property Get ActivePage as Access.Page
  With Me.MyTab
    Set ActivePage = .Pages(.Value)
  End with
End Property

Private Sub MyTab_Change()
  Select Case Me.ActivePage.Name
    Case "pgInvoice"
    Case "pgOrder"
    ...
  End Select
End Sub
 

Users who are viewing this thread

Back
Top Bottom