Accessing controls on a subform

P

Pete Davis

I have 3 forms. let's call them:

FormA, FormB, and FormC.

FormB is a sub form of FormA.

FormC is opened from a button on FormB. When FormC is closed, I want to
requery a control on FormB. How do I do that?

I tried Forms("FormB")!MyControl.Requery

This doesn't work. Access says: Microsoft Access can't find the form 'FormB'
referred to in a macro expression or Visual Basic code.

I've tried variations, but no matter what I do, I can't seem to get to the
control. I tried:

Forms("FormA").Controls("FormB")!MyControl.Requery
Forms("FormA")!FormB!MyControl.Requery
Forms("FormA").Controls("FormB").Controls("MyControl").Requery

Any ideas?

Thanks.

Pete
 
P

Pete Davis

This is close, but it's telling me "Object doesn't support this property or
method" for the Requery.
But if I look at it in the watch window up to this point:
Forms![FormA]![FormB].Form![Name Of Your Control] it says it's an access
field and it has the correct value for the field.

Any ideas?

Pete

--
http://www.petedavis.net
Byron said:
Try:
Forms![FormA]![FormB].Form![Name Of Your Control].Requery

Byron
-----Original Message-----
I have 3 forms. let's call them:

FormA, FormB, and FormC.

FormB is a sub form of FormA.

FormC is opened from a button on FormB. When FormC is closed, I want to
requery a control on FormB. How do I do that?

I tried Forms("FormB")!MyControl.Requery

This doesn't work. Access says: Microsoft Access can't find the form 'FormB'
referred to in a macro expression or Visual Basic code.

I've tried variations, but no matter what I do, I can't seem to get to the
control. I tried:

Forms("FormA").Controls("FormB")!MyControl.Requery
Forms("FormA")!FormB!MyControl.Requery
Forms("FormA").Controls("FormB").Controls ("MyControl").Requery

Any ideas?

Thanks.

Pete

--
http://www.petedavis.net


.
 
A

Albert D. Kallal

Remember, a sub-form control is just a control name. It DOES NOT necessary
have to have the same name as the actually sub form.

In fact, you can place the "same" sub form on a form 10 times...so, which
sub-form are you actually referencing? (hint: you use the name of the
control...not the name of the "form" name that is the sub-form).

So:

Forms![FormA]![NameOfSubFromContorl].Form![NameOfContorlInSubForm].Requery.


So, not in all cases is the name of the sub-form control is the same name as
the sub form. And, remember, a sub-form control is only a control. You can
have 5 controls that are sub-form controls and they ALL can even have the
same sub-form (you get multiple copies).
 

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