Displaying the correct Tab control on a form

  • Thread starter Thread starter Neil Warwick
  • Start date Start date
N

Neil Warwick

Can Anyone help me ou there with a small problem I have
with an application I'm writing?

I have a tabbed form with about 5 Tabs.
When I open it up at various times, I want it to display
maybe the 2nd, 3rd, 4th, or 5th Tab, depending upon
certain conditions.
I can test for the conditions quite easily using If..Then
type statements, but how do I open the form at the correct
Tab?
would expect to see sumthing like:-
DoCmd.Openform "frmTabForm", (Tab no.)

But I can't find any reference in any of my books etc on
how to achive this.

All help gratefully received.
 
There are a few ways that you could do this. I think the easiest to explaing
(as you were half way there with the idea below) would be to pass the page
number to the form using the open arg property. Then, in frmTabForm, use the
forms open event to move to the tab that was passed in as the open argument.
An example is as follows:

' In the code to open the form
DoCmd.Openform "frmTabForm", OpenArgs:=PageNumber

' The opening forms open event
Private Sub Form_Open(Cancel As Integer)

' Move to the page requested
Me.TabCtlName = Me.OpenArgs

End Sub

Just note that the pages start from 0 and not 1, so to move to the second
page in the tab control, you would set the open arg value (replace
PageNumber) above to be 1 (not 2 as expected).

HTH,

Neil.
 
Back
Top