Opening a subform based on the value of the main form

jboyle

New member
Local time
Today, 22:48
Joined
Nov 18, 2000
Messages
53
I have one main form that contains a field called [Process NAME].... I also have several sub forms that are unique to each process name. Each of these sub forms are different from one another.

If [PROCESS NAME] is "Build" on the record being shown on the main form, then I want a sub form called [BUILD] to be displayed as a sub form.

If [PROCESS NAME] is "TEST" on the record being shown on the main form, then I want a sub form called [TEST] to be displayed as a sub form.

If [PROCESS NAME] is "SHIP" on the record being shown on the main form, then I want a sub form called [SHIP] to be displayed as a sub form.

And so on...... Please understand that each of these sub forms are totally individualized.

Thanks in advance - John Boyle
 
Provided your subs are named like that, I think you can do it this way. I haven´t tried it though.

Dim strsubname as string

strsubname = me.process name
me.nameofsubformcontrol.sourceobject = strsubname
me.refresh

Put it as an after update event of your process name field.

Fuga.
 
Hi

I have done something similar by using this code behind the main form.

Private Sub Form_Current()

Select Case Me!process name
Case "build"
Me.sfrmwhatever.SourceObject = "frmbuild"

Case "ship"
Me.sfrmwhatever.SourceObject = "frmship"


End Select

Me!sfrmwhatever.requery
End Sub

On your main form, use the actual name of the subform to replace "sfrmwhatever", and where I have put "frmbuild", "frmship", replace with the actual form names you have given them.
Process name is the name of your field that determines the process and subform.
HTH
 

Users who are viewing this thread

Back
Top Bottom