Controlling a sub form or Tab control? (1 Viewer)

cjmitton

Registered User.
Local time
Today, 03:40
Joined
Mar 25, 2011
Messages
70
I have a job sheet created with the basic headers required, then depending of the type of job selected I want tab controls for the data they need access / complete.

This is due to Some jobs needing different data entering for letter merges or creating reports etc...

What / how do I control either a sub form with the relevent tab control / pages or can I control a tab control?

When I say 'control' I want the form when its loaded to select the relevent 'sub form' or 'Tab control' depending on the Job type?

I hope I've made my problem clear...
 

Trevor G

Registered User.
Local time
Today, 03:40
Joined
Oct 1, 2009
Messages
2,341
On a form you can place in a subform and have other subforms created, then you can adjust which subform is select, I use code for this with a variety of command buttons here is an example of the code

Private Sub cmdClientTeam_Click()
Dim sf As SubForm
Set sf = Me.frm02ClientTeam
sf.SourceObject = "frm02ClientTeam"
sf.LinkChildFields = "ProjectID"
sf.LinkMasterFields = "ProjectID"
End Sub
 

cjmitton

Registered User.
Local time
Today, 03:40
Joined
Mar 25, 2011
Messages
70
Trevor,

Sorry, just so I get this correct in my head (too much going on and not enough space!).

Your example here when a button is clicked, in the sub form on your current form it opens a form called frm02ClientTeam and Links 'ProjectID' from the master form to the child form to pick the correct dataset?

Or have I got that wrong?
 

cjmitton

Registered User.
Local time
Today, 03:40
Joined
Mar 25, 2011
Messages
70
Thanks for that Spikepl, I'll have an investigate.
 

Trevor G

Registered User.
Local time
Today, 03:40
Joined
Oct 1, 2009
Messages
2,341
Trevor,

Sorry, just so I get this correct in my head (too much going on and not enough space!).

Your example here when a button is clicked, in the sub form on your current form it opens a form called frm02ClientTeam and Links 'ProjectID' from the master form to the child form to pick the correct dataset?

Or have I got that wrong?

Slightly wrong, the main form has a command button and the subform is then switched to which ever form I want and the link is the Master and Child ID fields.
 

cjmitton

Registered User.
Local time
Today, 03:40
Joined
Mar 25, 2011
Messages
70
Thanks Trevor, I'm going to have a play now...

Quick question - The line:
Code:
Set sf = Me.frm02ClientTeam
Is that the name of the current / active sub form on the main form?
When the button (on main form) is clicked is loads:
Code:
sf.SourceObject = "[B][COLOR=red]frm02ClientTeam[/COLOR][/B]"

Sorry for being a pain...
 

Trevor G

Registered User.
Local time
Today, 03:40
Joined
Oct 1, 2009
Messages
2,341
when the form is first opened there will be a default subform attached, the button would change the subform and then attach the source and Master/Child fields.


Private Sub cmdClientTeam_Click()
Dim sf As SubForm
Set sf = Me.frm02ClientTeam 'Default Subform name
sf.SourceObject = "frm02ClientTeam" 'Change to another form
sf.LinkChildFields = "ProjectID"
sf.LinkMasterFields = "ProjectID"
End Sub
 

Trevor G

Registered User.
Local time
Today, 03:40
Joined
Oct 1, 2009
Messages
2,341
Your welcome I hope it helps with your database.:);)
 

cjmitton

Registered User.
Local time
Today, 03:40
Joined
Mar 25, 2011
Messages
70
Oh yes it has...

I now have the following code on my 'on load' for the main form...

Code:
Private Sub Form_Load()
Dim JType As String
    JType = Me.J_Type
Dim Sformtype As String
    Sformtype = "frm_Jobs_Jtype" & JType & ""
Dim sf As SubForm
Set sf = Me.frm_Jobs_DefSub
sf.SourceObject = Sformtype
'sf.LinkChildFields = "ProjectID"
'sf.LinkMasterFields = "ProjectID"

And happily switchs forms! Thanks once more.
 

Users who are viewing this thread

Top Bottom