Solved

how to change label name dynamically

Posted on 2009-05-06
7
719 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
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…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

856 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