Full Version: Is It Possible To Allow User To Edit Labels In Code?
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
ccIces
I have a few forms where different areas use different terminology to describe the same item. For example, I have a shift schedule that shows "Supervisor" at the top as a label that is attached to the control that shows the name of the supervisor. Some areas would like to change the label to their local terminology.
Is there a way to change a label in an open form? Say double click on the existing label and use an input box to get a new value?
I have look around and I am finding that the changes won't save unless it is done to the form in design mode.

Maybe by double clicking on a label a form opens listing all of the labels that can be changed? and then when that form is closed does the silent open of the form needing the change to design mode etc?

That seems like the long way around.. any other thoughts?
GroverParkGeorge
It may be more work than you need/want; but you can create user configurable settings, which you would be able to store in a configuration table. Look for samples or demos here. I THINK I've seen some here. I have a partial demo on my website. The one you'd want for this purpose is called, "Previous Weekday Demo" and it uses a similar table to change labels on the fly from a language configuration table. I'm pretty sure there have been more robust demos or samples, though. I want to say HiTechCoach has one, but I'm not really sure.
jleach
You can change the label's caption easily without needing to go into design mode. Something like this:

CODE
Private Sub MyLabel_DoubleClick()
  Dim strNewCaption As String
  strNewCaption = InputBox("Enter a new caption for the label")

  Me.MyLabel.Caption = strNewCaption
End Sub


Based on that, you can see how you would configure a table, etc to hold some values as George suggested, or however else you would like them handled, but changing the label text theselves is cake.

Cheers,
ccIces
True, that code does change it but only in the current opened form. When you close the form, it reverts to the original name.
GroverParkGeorge
I think "PERMANENT" changes need to be stored in a configuration table which is under the user's control. Far easier to maintain.
theDBguy
Hi,

For what it's worth, I agree with George (and Jack) because dynamically storing the change in the form's Design would mean that you cannot distribute compiled versions of your app.

Just my 2 cents... 2cents.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.