switching subforms at run time

  • Thread starter Thread starter deluded.soul
  • Start date Start date
D

deluded.soul

Hi everyone,

I have a form which has a subform. Now based on the user selection, I
want to replace this subform with another at run time.

One approach I tried was to have both the forms on the screen and have
one of the invisible and switch the visibility states when the user
makes a selection. However, if I make the topmost form invisible, the
underlying fom still does not show for some reason.

Anyone has any suggestions, I would be grateful.

Cheers,

P
 
There is no need to load two subforms if you need only one at the time.

To change the subform use the SourceObject property:

Me.SubFormControlNameOnMainForm.SourceObject =
"TheFormYouWantAsSubForm"
(in one line)

Example:

Create a command (or toggle) button on your main form

Private Sub YrButton_Click()

Me.SubFormName.SourceObject= _
IIf(Me.SubFormName.SourceObject="Form1","Form2","Form1")

End Sub

Regards/JK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top