subform instance

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an unbound form instance with subforms on it. When exiting the
subform, I would like to close the subform instance. The subform is on a tab.
WHen the user moves to that tab, I instantiate the subform. But if I move off
that tab and back, I get an error that the instance already exists.

Thanks a lot! (been working on this for days)
 
I have an unbound form instance with subforms on it. When exiting the
subform, I would like to close the subform instance. The subform is on a tab.
WHen the user moves to that tab, I instantiate the subform. But if I move off
that tab and back, I get an error that the instance already exists.

Thanks a lot! (been working on this for days)

only assign it if it's empty

if subformControl.controlsource="" then
subformControl.controlsource="Myform"
endif
 
Hi Sam

How do you load the subform control? By setting its SourceObject property?
If so you could blank out the subform with:
Me.[sub1].SourceObject = vbNullString
where "sub1" represents the name of your subform control.

If you only need one subform loaded at any one time, you could place the
subform control directly on the main form, i.e. not on the page of the tab
control. Then use the Change event of the subform control to load the
desired form into the subform control. (One thing to watch out for when you
do this is that Access is likely to set the LinkMasterFields/LinkChildFields
automagically, so you may need to check it gets it right, or clear them if
you don't want the properties set.)

If that's not what you are doing, will check back tomorrow.
 
I don't have a direct answer as to why you're getting the error message.
Apparantly you are not completetly disposing of it.

But the usual way of dealing with a subform in a tab control setting is to
simply set its Visible property to true or false as you move and from that
tab it is associated with.

TomU
 
Back
Top