Open form on required tab (1 Viewer)

YNWA

Registered User.
Local time
Today, 02:58
Joined
Jun 2, 2009
Messages
905
Hi,

I have a list box that displays records. When i double click a record it opens the form needed.

However I want it to open the form but default to a specific tab. But when it goes to the tab, the subform within it needs to match the ContractID of the record they double clicked on in the search form?

I currently have this which opens the Client Form based on the ClientID of the listbox query search results and the client id of the main record.

Code:
Private Sub SearchResults_DblClick(Cancel As Integer)
If CurrentProject.AllForms("frm_Clients").IsLoaded Then
     DoCmd.Close acForm, "frm_Clients"
End If
  DoCmd.OpenForm "frm_Clients", acNormal, , "[ClientID] = " & Me.SearchResults.Column(0)

End Sub

Any ideas?

So in theory If doubleClick then open Client Form on Tab3 where subform Contract field ContractID is matches the ContractID in on the search results?
 

JHB

Have been here a while
Local time
Today, 03:58
Joined
Jun 17, 2012
Messages
7,732
Can't you use the Client Form load event to open a specify tab, like below where Page3 is shown when the form open?
And use the Client Form form's open argument (OpenArgs) to set subform so that ContractID is matches the ContractID search results?
Code:
Private Sub Form_Load()
  Me.Page3.SetFocus 
End Sub
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 11:58
Joined
Jan 20, 2009
Messages
12,856
If the form must be opened at diferent tabs under other circumstances then pass 3 as the OpenArgs argument of OpenForm.

Then in the form's module:

Code:
Private Sub Form_Load()
 
With Me
  If Len(.OpenArgs & "") > 0 Then .tabcontrol.Pages(.OpenArgs).SetFocus 
End With
 
End Sub

So whenever you want a particular tab open simply put it in OpenArgs.
 

Users who are viewing this thread

Top Bottom