Sub References

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

Guest

Trying to refer a control on a sub form another unrelated sub. I looked at
the Access Web sit and tried to tweak how I reference it but no dice. This is
what I'm using now. Can anyone tell me what I'm doing wrong?

If Me.Parent!Display_SLA_Details_Sub.Form.Paid_In_Advance = True Then
 
That's the right idea.

If it doesn't work:
- Open the main form in design view.
- Right-click the edge of the other subform control, and choose Properties.
- Check the Name property (Other tab of Properties box).
The Name of the subform control can be different from the name of the form
loaded into it (its SourceObject).

If you still can't get it, press Ctrl+G to open the Immediate window, and
start entering things such as:
? Forms("MyMainForm").Controls("Display_SLA_Details_Sub").Name
 
I entered the command into immediate and it came out fine. But when I try to
refer to it in code I get:
"Run-time error 2455:
You entered an expression that has an invalid reference to the property
Form/Report.

<=Confused
 
So ask it what kind of control it is:
? TypeName(Forms("MyMainForm").Controls("Display_SLA_Details_Sub"))

If it is a subform control, see if it has a SourceObject:
? Forms("MyMainForm").Controls("Display_SLA_Details_Sub").SourceObject

And so on...
 
Hey, thanks so much for you help.

It's a subform and the Source object is a query that happense to have the
same name - Display_SLA_Details_Sub . That all worked fine.

Do you have a link to other debugging commands that I may use now and in the
future. I hate bugging people about small details like this

cheers
 
Yes, that little Debug window is pure gold, isn't it.

Once you start to know what things are called, you can type something in the
Debug window, move the cursor back into the word, and the press F1 to get
help on that topic.

Other suggestions from Microsoft:
Tips for Debugging Visual Basic for Applications Code
at:
http://support.microsoft.com/default.aspx?scid=kb;en-us;210143
 

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

Back
Top