Refer to (change) subform color in Sub code

M

Maarkr

I give up...tried variations and I have the 'syntax for main/subforms'
handout, but I can't get it... trying to change the subform color
(detail.backcolor=16764057) in a sub procedure. Still mixed up on Me. or Me!
, if I refer to name of sub control or the formname, if I use Form or Forms...

it's not this but what will work?
Me!Child1.Form.Detail.backcolor=16764057
why does it say 'field not found'...why does it expect a field after the
Form! bang?
why isn't Detail a part of the form.controls object?
how do you get to the Detail member of the Subform? the subform is the only
object in the object browser that refers to Detail
inquiring minds want to know...thanks
 
D

Douglas J. Steele

I'm assuming that this code is being run from the parent form.

Are you sure that the name of the subform control on the parent form is
named Child1? Depending on how you added the subform to the parent form, the
name of the subform control can be different than the name of the form being
used as a subform.
 
M

Maarkr

found more info on the Micro$oft site, kb 209099:

Forms![main form name]![subform control name].Form![control name]
but since I wasn't referring to a control, I used 'Form.' I thought it was
odd that nowhere could I find how to reference a member of a form.

Forms!MainFormName!Child2SubCtl.Form.Detail.BackColor = 16764057

I also thought this was interesting from the site...
"a subform on a main form is not a form, but is a control just like a text
box or a list box. You must refer to a subform as a control rather than a
form, and specify the Form identifier following the subform control name
reference to gain access to the controls on a subform."

it's nice to learn something....but too bad I'll forget it by next week
 

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