changing TextBox Caption

L

Luis

Hello.
I have a form ("MainForm") with a subform ("Main_SubForm"). The subForm used
as Source Object ("SF_SourceObj") has a Text Box that i want to chabge the
caption via code.
I'm using the following code:
Me!SF_SourceObj.Form!TextBox1.Caption = "Test"

This is producing the following error:"Run-time error '2465' - Microsoft
Office Access can't find the field 'SF_SourceObj' referred to in your
expression."

Why does this happen?

Thanks
Luis
 
D

Daryl S

Luis -

If the button and the textbox are both in the subform, then the reference
would be:

Me!TextBox1.Caption = "Test"
 
L

Luis

No, they aren't.

The button is in MainForm and the TextBox is in SF_SourceObject form.
 
A

AG

A text box does not have a caption property.
If it has an attached label then you can use
Me!Main_SubForm.Form!TextBox1.Controls(0).Caption = "Test"

If the label near it is not attached, then change the label's caption
directly
Me!Main_SubForm.Form!LabelforTextBox1.Caption = "Test"
 
K

Klatuu

When addressing a control on a subform from a main form, you do not use the
name of the form object being displayed in the subform control. You use the
name of the subform control on the main form. The syntax is:

Me.SubformControlName.Form.ControlName.ControlProperty
But, text boxes do not have a caption property. You would have to use a
lable control.
 
L

Luis

TextBox1 is a control within SF_SourceObj.
Main_SubForm is the name of the SubForm\SubReport section.
Maybe i didn't explained me clearly on the first post.
 

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