Solved

how to change label name dynamically

Posted on 2009-05-06
7
705 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
  • 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
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 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now