VBA Field Label Caption Change won't stay

Monsora83

Registered User.
Local time
Today, 11:01
Joined
May 16, 2011
Messages
41
I am using:

Forms(strFormName).Controls(strFieldLabelName).Properties("Caption").Value = Me.New_Field_Label_Caption

To change the caption of some labels. The code works fine so if I run it then open the form, the label has the proper new caption, however if I close and reopen the database, it revents to its original caption.

Will I just have to use an 'On Load' event for the form every time it's opened, or is there a way to make the change stick?
 
On which event you are using the code? On form Load OR current event of the form might solve the problem.
 
On which event you are using the code? On form Load OR current event of the form might solve the problem.

Currently I'm not using an On Event. I have a button set up on another form that udates all the changes for captions in the database.
 
well what you are doing is temporarily overwriting the captions from the values you set when you designed the form, so they won't "stick".

The question is - why are you changing captions? What are you "really" trying to achieve?

Note that your syntax for this is unusual - which implies you got this code from somewhere without maybe fully understanding what it all meant.
 
The question is - why are you changing captions? What are you "really" trying to achieve?

So that users can rename the label they use as a process that will constantly be redefined as time goes, while still housing the same field data. Else I will containly be asked to change it.

Note that your syntax for this is unusual - which implies you got this code from somewhere without maybe fully understanding what it all meant.

Indeed, which is why I posted it. Googled it along with some code posting on these forms.

Users with proper privledges will be allowed to rename specific labels on a form when needed, so when the time comes to enter data, the field will be named as they want it.
 
You would have to store the captions in a table and read and assign them in the load event of every form where they appear.

If you wanted to have mulitple language versions of a database that's the kind of thing you'd have to do too.
 
Last edited:
Alternatively, you could open the forms in design view (in code) before setting the captions and then save it. That would fail in a compiled database and runtime only access wouldn't cope with it either.
 
In order for the Caption changes to persist you'd have to open the target Form in Design View from another Form. You'd
  • Open the Target Form in Design View
  • Make Caption changes
  • Close Target Form, saving changes
The code to use would be
Code:
DoCmd.OpenForm "TargetForm", acDesign
 
 Forms("TargetForm")("TargetLabel").Caption = "Whatever You Like""
    
 DoCmd.Close acForm, "TargetForm", acSaveYes

Linq ;0)>
 
I would like to have a form when loaded show a label which dynamically change the customer's name. Can you please suggest how to get it? I'm novice. Thanks
 

Users who are viewing this thread

Back
Top Bottom