Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to change label name dynamically

Posted on 2009-05-06
7
Medium Priority
?
739 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 85
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 85
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 1000 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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 …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

730 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