Tabs

bstice

Registered User.
Local time
Today, 10:42
Joined
Jul 16, 2008
Messages
55
HI all,

I have a form with two tabs. Depending on which tab is open, I would like to print out a report with that information displayed on the form. I have both reports built, but I need to know how I can tell with VBA that a particular tab is displayed and the other behind it. Thanks

Brennan
 
You don't say how you're triggering this, but something like:

Code:
If Me.TabControlName.Value = 0 Then
  'Run report for First Page
Else
  'Run report for Second Page
End If
The index for tabbed pages is Zero-based so

Me.TabControlName.Value = 0 would be the 1st page
Me.TabControlName.Value = 1 would be the 2nd page
Me.TabControlName.Value = 2 would be the 3rd page
 
Awesome - thanks. I'd give you more reputation, but I recently gave you some for help you have already given me and the system won't let me. Thanks again.

B
 
I do this...
Code:
Private Property Get ActivePage as Access.Page
[COLOR="Green"]  'returns an object reference to the current page in the tab MyTab[/COLOR]
  With Me.MyTab
    Set ActivePage = .Pages(.Value)
  End With
End Property
Then I can determine what page is current using the Name property, which is much easier for me to understand when I review this code 10 months from now, and have to figure out what it does. And I can freely re-order pages without breaking anything.

Code:
Private Sub MyTab_Change()
  Select Case ActivePage.Name
    Case "pgAddress"
      [COLOR="green"]'...[/COLOR]
    Case "pgPhone"
      [COLOR="green"]'...[/COLOR]
    Case "pgNotes"
     [COLOR="green"] '...[/COLOR]
  End Select
End Sub
 

Users who are viewing this thread

Back
Top Bottom