Set TabControl focus from seperate form (1 Viewer)

rainman89

I cant find the any key..
Local time
Yesterday, 20:54
Joined
Feb 12, 2007
Messages
3,016
Hi all,
I have a query (qryCandD that returns a case if they have had a certain action performed on them. there is a form (frmCandD) with the query as its recordsource and on this i have a button that opens the mainform (frmCase) to the record that was returned from the query.

This main form has a tabctrl on it.
My question is how do i open the form to a certain tab, without setting it up in the on open event?
i want this to be done with the button on the frmCandD button, and thought i could do that using a
Code:
TabCtl.Pages(3).SetFocus
but i think this method has to be invoked in the form itself. and cant be done from an outside form.
am i wrong?
 

missinglinq

AWF VIP
Local time
Yesterday, 20:54
Joined
Jun 20, 2003
Messages
6,423
I think you have to set it up on the Form_Open event, but you can do so provisionally, so it doesn't happen if you open the form independently. Don't have time to actually try this out, but a general approach would be to assign the page number of the tab you want open to the OpenArgs of the form open command, then in Form_Open do something like

Code:
If Len(Nz(Me.OpenArgs, "")) > 0 Then
   PgNum = Me.OpenArgs
   TabCtl.Pages(PgNum).SetFocus    
End If
 

rainman89

I cant find the any key..
Local time
Yesterday, 20:54
Joined
Feb 12, 2007
Messages
3,016
Where would i set up the open args? could it be done within the other forms command button?

Ideally i would like each query to open to its respected tab(ie tab3 = CandD info, tab 4=enforcement) and i have a query where they can search for each case with certain info
 

Users who are viewing this thread

Top Bottom