Solved

how to change label name dynamically

Posted on 2009-05-06
7
726 Views
Last Modified: 2013-11-29
Hi everyone:
I have noticed that Access does not change the label name dynamically. Is there a way of changing the label name in the form without going to the form and typing in.
for example: at first, I created a field name "what is your age" and later on I change it to "age" from the table. on my form only the source control got changed not the label.
I have a bush of changes coming in in this project and I really want to find a way to make those changes without going through the form. thanks for your suggestions
0
Comment
Question by:LougaLo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 84
ID: 24316065
Do you mean the lable that's associated with your control? If so, why is it important to change the name? You may have good reasons for doing this, but unless you've got code that interacts with your labels then the names aren't really important.

That said, Rick Fishers Find & Replace utility could help with this (www.rickworld.com).
0
 

Author Comment

by:LougaLo
ID: 24317054
LSMConsulting:

thanks for your prompt response.
I installed the shareware "Find and Replace 9.0 for Microsoft Access 2000, 2002/XP, 2003" but this is not doing the real change I needed . it is changing just the Source Control not the label linked to the source control nor the field name on the table. I sent an email to the website support exposing my need and requesting if this is possible through their product. otherwise it looks like a great Add-on and affordable too.

I come from a FileMaker world. In filemaker when I change  a field name on a table definition, it got changed in the form too without me going and hard coding the label name. I wonder if this is possible in Access.
0
 
LVL 16

Expert Comment

by:Chuck Wood
ID: 24318533
I think you mean the label Captions. Normally, you wouldn't do this. You generally design the tables first and, when that is done, create the forms bound to the tables. That said, I have attached a (really clunky) work-around code snippet that should do what you want. Of course this will only work for bound text boxes. Combo boxes, for example would have Control Sources different (and larger) than their label captions (e.g. SELECT ID, Deparment FROM tblDepartments).

Please let me know if you have any questions.
Private Sub Form_Load()
    ' set the label captions to their text box control source (field) name
    lblManager.Caption = txtManager.ControlSource
    lblDepartment.Caption = txtDepartment.ControlSource
    ' . . .
End Sub

Open in new window

0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 84
ID: 24319204
I see ... this doesn't happen in Access. cwood has shown you how this can be done with code, but it's not automatic when you make table changes.
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 250 total points
ID: 24323438
LougaLo,

As has been stated, Access, (nor any other program that I know of) will not do this for you "automatically"
The reason being that the "Label Caption" is what "Humans" need to see.
The other names are typically what the program reads internally.
Also, typically you will have your naming convetion in place that will supercede any default name.

Since the "Label Caption" is what "Human Beings" will be using, your field might be "cFN" or "WhatIsYourName", but the label caption will say "Customer First Name" or "What is your Name"
Make sense?
;-)

Also keep in mind that the Name of the "Filed" and the name of the "Control" may be different as well.

For example:
Field Name: FN
Label Name: lblFN
Label Caption: First Name
TextBox Name: txtFN
TextBox ControlSource (Source Field): FN

This follow a "Naming Convention".
Every developer should follow some sort of Naming convention.
Here are the two most popular for Access/VBA:
LNC:
http://en.wikipedia.org/wiki/Leszynski_naming_convention
RVBA:
http://www.xoc.net/standards/default.asp

Please consider adopting one.
;-)

As far as changing them en masse goes, here is one of the popular "Bulk Renaming" products:
http://www.rickworld.com/products.html

;-)


JeffCoachman
0
 

Author Comment

by:LougaLo
ID: 24358860
cwood-wm-com: this codes do not allow change when it done through the table definition.

boag2000: you made valid points. the links were very helpful.

thank you all.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24360373
Thanks

Jeff
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delete table fields 3 48
Can not open the Access Help ? 3 40
Access Report via Windows Desktop Shortcut 12 44
Access 2003, percentage between two fields 18 18
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question