audit Trail to read the caption of the field from the table

fathi

New member
Local time
Today, 15:54
Joined
Dec 12, 2006
Messages
6
Hi every one

i have an application with an audit trail module, i do read the table name , field name,old value, new value. but the lables of the fields at my forms are changed to arabic language

for example

lets say i do have a table
the name of one field is Name
on the form the label of this field is Lawyer Name

now the client is asking me to show the ( Lawyer Name ) not the field name ( Name ) in the audit trail to know the changes were made.

I thought to go to the tables and on each field 's caption i shall add in arabic the same as in my form

I am trying to read the caption of the field from the tables

i hope you understood what i mean

if you show me the code to do that , it would be highly appreciated

thanks in advance
 
The field labels, by default, are called "Label<n>", where <n> is a number. They have a property called "Caption". To read the caption, you might use this:
Code:
str1 = Label23.Caption
You may want to rename your labels to something more meaningful, like 'lblName' or similar.
 
Caption of A field

Jonathan Kok said:
The field labels, by default, are called "Label<n>", where <n> is a number. They have a property called "Caption". To read the caption, you might use this:
Code:
str1 = Label23.Caption
You may want to rename your labels to something more meaningful, like 'lblName' or similar.


Thanks jonathan for your reply

my question exactly is

how can i capture the caption of any field in a table from a module . where i can read ( capture) the fields name but not the caption from the fields property at the table ?????

i hope my question is clear

thanls a lot
 
The trouble is...it's not clear.
On a form, there are labels, and there are textboxes tied to fields. Two different things. Captions only apply to labels--textboxes do not have captions.

If you are refering to the Caption property of a Field as set in Table Design mode (NOT on a form), then it's possible.
This code pops up a message box with the field's caption:
Code:
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field

Set db = CurrentDb
Set tdf = db.TableDefs("TableName")
Set fld = tdf.Fields("FieldName")
MsgBox (fld.Properties("Caption"))
 
As long as the form was created entirely using wizards (either form wizard or a specific control wizard), the Label associated with the control is identifiable as a property (.Label ??) of the control. Therefore it is at worst a couple of steps to find the control's label's caption.

If you created the control and label by hand, they were created indepently and there was no wizard to fill in the label property, so you have to go back and retro fit. I regret I don't recall the exact property you want or where it is located, but I remember being able to find it. (Ain't it hell when your memory starts to go?)
 
If it does exist...Microsoft buried it well.
You CAN reference a label's associated textbox via the 'Parent' property, but there's no reciprical 'Child' property on the textbox.

EDIT: Found it. Buried well.

Returns the caption of a textbox's associated label:
Code:
Dim ctl As Control
Set ctl = Me.FieldName


MsgBox (ctl.Controls.Item(0).Caption)
OR
MsgBox (ctl.Controls(0).Caption)
Found it here:
http://www.aadconsulting.com/aadtips.html
 
Last edited:

Users who are viewing this thread

Back
Top Bottom