Problems referencing Subform Control from another subform

J

John Lane

How do you reference a subform control when "in" another subform? I want to
use the On Current event in subform a to populate data in subform b.

Using the syntax below in the On Current Evetn of subform "a" I get the
error message: "You entered an expression that has an invalid reference to
the property Form/Report". When I put the statement in the main form, it
works. Thanks.

MsgBox "y = " & Forms!frmAccountRegister!subfrmTabs!C_CN
 
A

Arvin Meyer MVP

John Lane said:
How do you reference a subform control when "in" another subform? I want
to
use the On Current event in subform a to populate data in subform b.

Me.Parent.NameOfSubformB.Form.ControlName
 
J

John Lane

Doesn't work. Same message. Am usign Access 2007 i that's any help. Also, in
the off chance you typed a dot when an ! oughtas be, I tried it both ways and
still didn't work.
 
D

Dirk Goldgar

John Lane said:
How do you reference a subform control when "in" another subform? I want
to
use the On Current event in subform a to populate data in subform b.

Using the syntax below in the On Current Evetn of subform "a" I get the
error message: "You entered an expression that has an invalid reference to
the property Form/Report". When I put the statement in the main form, it
works. Thanks.

MsgBox "y = " & Forms!frmAccountRegister!subfrmTabs!C_CN


Double-check the name of the subform. In your expression, you must use the
name of the subform *control* on the parent form, which may or may not be
the name of the form object it displays.
 
J

John Lane

Ah, the wonderful inconsistencies of Microsft software! After all the
subforms are "fully" open, it works. I looks like it fails when the forms
first open up. Maybe there is no reference to the 2nd subform when the On
Current fires on the first subform. Or something. I am sure the Microsoft
developers have some perfectly plausible, yet useless answer why.
 
D

Dirk Goldgar

John Lane said:
Ah, the wonderful inconsistencies of Microsft software! After all the
subforms are "fully" open, it works. I looks like it fails when the forms
first open up. Maybe there is no reference to the 2nd subform when the On
Current fires on the first subform. Or something.

Possibly. Subforms are loaded before their parent forms; that's a given.
For the rest, I can see that it might be a timing problem as independent
threads execute.
I am sure the Microsoft
developers have some perfectly plausible, yet useless answer why.

I don't se the value of that remark.
 

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