changing TextBox Caption

  • Thread starter Thread starter Luis
  • Start date Start date
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
 
Luis -

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

Me!TextBox1.Caption = "Test"
 
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"
 
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.
 
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.
 
Back
Top