subform control references

G

Guest

I have a form with 2 seperate subforms within the main form. On changing a
combo box in the 1st subform (all unbound fields), I would like the contents
of thew 2nd subform(again all unbound fields) to be completely cleared. I
have tried issuing the individual field clearances as below with no success :-
Forms!MainFormName.subformName.Forms!controls!controlname = ""

As It is being issued from the On Change event in the 1st subform, do I need
to change the reference in the statement?

Cheers,
Steve
 
R

RuralGuy

Here's a link to a good reference on the subject.
http://www.mvps.org/access/forms/frm0031.htm

In this particular instance your reference would be:
Forms!MainFormName.subformName.Form!controlname = ""

You could also use:
Me.Parent.subformName.Form!controlName = ""

You could also create a Public SubRoutine in the second form that did all of the
clearing for you and then call it from the first form:
Call Me.Parent.subformName.Form.ClearAll()

I have a form with 2 seperate subforms within the main form. On changing a
combo box in the 1st subform (all unbound fields), I would like the contents
of thew 2nd subform(again all unbound fields) to be completely cleared. I
have tried issuing the individual field clearances as below with no success :-
Forms!MainFormName.subformName.Forms!controls!controlname = ""

As It is being issued from the On Change event in the 1st subform, do I need
to change the reference in the statement?

Cheers,
Steve

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
G

Guest

Thanks for the reply, I had already tried your 1st 2 suggestions to no avail,
I always get the same message :-
Run time error 2465
Application-defined or object defined error.

I was just wondering about the fact that invoking the commands from a
subform causes the problem,as I think I have explored the usual solutions
already.
 
G

Guest

Thanks RuralGuy. I have already tried the 2 suggestions. The article is
interesting but pertains to the fact that subform 2 resides inside subform1,
whereas I have 2 seperate unnested subforms. I have tried countless different
combinations to try and get the thing to work correctly, all to no avail.
 
D

Douglas J Steele

Post the exact code that you're using that generates the error.

There's a subtlety that's often overlooked.

In

Forms!MainFormName.subformName.Form!controlname

subformName is the name of the container that holds the subform. That may be
different than the name of the actual form that's being used as a subform.
Access defaults them to be the same, but I always rename the container to
make it clear when I'm talking about the container vs. the form.
 
R

RuralGuy

Did you notice I not only removed the 'controls' reference from your original
post but I removed the 's' from the second Forms. As Doug stated, the
'subformName' in your reference is really the name of the SubFormControl.
SubForms are displayed on forms by means of a SubFormControl. Access defaults
the name of this control to the same as the SubForm but it does not have to
remain so. You know you are looking at the SubFormControl when the data tab
shows the Link Master/Child Field entries. The Other tab of this property sheet
has the name of the control.

Thanks RuralGuy. I have already tried the 2 suggestions. The article is
interesting but pertains to the fact that subform 2 resides inside subform1,
whereas I have 2 seperate unnested subforms. I have tried countless different
combinations to try and get the thing to work correctly, all to no avail.

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 

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

Top