Renaming a control's caption property?

  • Thread starter Thread starter DJW
  • Start date Start date
D

DJW

I have a label on a form named "label45". In the form's design view, the
caption property is blank.

When I open a form, I want the caption value on the form to be renamed to
"Tested". However, I want this to be a permanent change, not just while the
form is open. In other words, if I go back to the form's design view, I
want to see the new name value listed after "Caption" and not remaining
blank. I want to do this with visual basic code.

How do I do this? I am using the following code right now but
unfortunately it is only temporary. When I close the form and go to the
form's design view, the value "Tested" is not present and the caption value
is still blank.

Private Sub Form_Open(Cancel As Integer)

Me.Label45.Caption = "Tested"

End Sub

Any help would be greatly appreciated. Thank you.
 
You would need to open the form in design view, change the caption property,
and then save the form.
 
DJW said:
When I open a form, I want the caption value on the form to be renamed to
"Tested". However, I want this to be a permanent change, not just while the
form is open.

You can't do it from *this* form. You must do it from another procedure in
another form or module.

Dim frm As Form

DoCmd.OpenForm "frmTest", acDesign
Set frm = Forms("frmTest")
frm.Controls("Label45").Caption = "Tested"
Set frm = Nothing
DoCmd.Save acForm, "frmTest"
DoCmd.OpenForm "frmTest"
 

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