forms_subforms (1 Viewer)

S

Stefano

Guest
Hi there,
I am writing you for I have a HUGE problem with our dear access. I hope you can help me my love ones!
The problem is the following one:
I would like to load a sub-form on a form but the sub-form is not always the same 'cause it changes depending on the data format I have to enter in the main form.
Is it feasible to do it with our dearest Access?
I am looking forward to reading your answers!
G'day mates,
Stefano Adami (Milan, Italy)
 

Tay

likes garlic
Local time
Today, 11:20
Joined
May 24, 2002
Messages
269
For example. If on your main form, the scheme type = A, then you want subformA to load, if scheme type = B, then you want subformB to load?

Build all of the forms you want to use as your specific subforms (eg, subformA, subformB etc). Then place a subform control in your main form, calling it for example, frmSchemeTypeSubform, and link it to your main form. SchemeType is the combo (or whatever) on your main form you want to choose from.
Then in the On Current event of the main form, add what is below, changing the text to match whatever your field/subform names are.

Private Sub Form_Current()

Select Case Me!SchemeType

Case "SchemeTypeA"
Me.frmSchemeTypeSubform.SourceObject = "subformA"

Case "SchemeTypeB"
Me.frmSchemeTypeSubform.SourceObject = "subformB"

End Select

Me!frmSchemeTypeSubform.Requery

End Sub

Hope that made sense.:)
 
S

Stefano

Guest
Thanks a lot Tay!
 

insanity

Monkeys do the work!
Local time
Today, 11:20
Joined
Jan 8, 2002
Messages
14
I've benefited from this ... thanks very much ..

But now i've got another question, my form is slightly different in the way that I have a main form (frmServiceCharges) with 3 nested subforms (1. fsubServiceChargesList, 2. fsubServiceChargesEntry, 3. fsubServChargeSLA)

The way I *had* it set up was all three subforms load and two are visible = false. There was a option group on the footer and when you selected either "List", "Service" or "Agreement" made the relevant subform visible.

As more and more service charges are put into the system loading three subforms on the same data set become "chunky" and slow.

I changed it to the above and it's much quicker. The problem I am now encountering is when you choose an option, it loads the form, but how to do "hide" it again or unload it. If I type .SourceObect = "" then I get an error saying "Cannot set a subform to zero-length in Form view" (slight modified msg!)

How can I "unload" the forms again. If I set visible = false then when you have to re-select I'll need to set a .visible = true when they re-select it, which defeats the purpose .. HELP! please ...

Alternatively, is there way you can "Load" and "Unload" subforms?

Thanks in advance for your help!! and i'll keep trying different ways!
 
Last edited:

Users who are viewing this thread

Top Bottom