Caption change on table

  • Thread starter Thread starter gg
  • Start date Start date
G

gg

I would like to change the captions of some table fields based on other
criteria. I can change captions easily on forms and reports, but would like
to do it on the table. Is it possible to do it with code?
 
It is possible.
Look for references to the DDL (data definition language) component in SQL.
I believe that to rename a column you would need to ALTER TABLE tblName ADD
a column; move data into it from the existing column with an UPDATE query
and then ALTER TABLE tblName DROP the old column.

Some simple info here: http://support.microsoft.com/kb/180841

Regards

Kevin
 
I may have misread your question. Do you want to rename the Columns/fields
or just the labels?
 
Assuming function is in same accdbs, and only one field needs to be
updated

Private Function Update_Field_Caption(str_tblname As String,
str_fldname As String, str_newcaption As String)
CurrentDb().TableDefs(str_tblname).Fields(str_fldname).Properties
("Caption").value = str_newcaption
End Function
 
What I am trying to do is, with code, to do the same thing that you do
manually in the design view of a table when you fill in the caption property
for a field name. I think that your reply covers that. I just gave your
reference a quick look, and will study. I am also going to try the next
answer from egerds Thanks.
 
Thanks for quick reply. I tried code belowwith a table named 99JS a with a
text field called OldName.

CurrentDb().TableDefs("99JS").Fields("OldName").Properties("Caption").Value
= "NewName"

I get an error message :
Ambiguous Name Detected: Update_Field_Caption

An aside-I have Ac2000 and it won't display help screen for TableDefs. Is
this my machine or another of those things that makes Ac2k infamours?
 
I'm a little redfaced-the error I reported (ambigous etc) was caused by my
clutter on the code screen. I got rid of that, but now I get this error:
"Run-time error 3270 Property not found". Any ideas?

The expression I am using is:
CurrentDb().TableDefs("99JS").Fields("OldName").Properties("Caption").Value
= "NewName"

where OldName is a field name in table 99JS
Thanks again.
 
I'm a little redfaced-the error I reported (ambigous etc) was caused by my
clutter on the code screen. I got rid of that, but now I get this error:
"Run-time error 3270 Property not found". Any ideas?

The expression I am using is:
CurrentDb().TableDefs("99JS").Fields("OldName").Properties("Caption").Value
= "NewName"

where OldName is a field name in table 99JS
Thanks again.
 
gg said:
What I am trying to do is, with code, to do the same thing that you do
manually in the design view of a table when you fill in the caption property
for a field name. I think that your reply covers that. I just gave your
reference a quick look, and will study. I am also going to try the next
answer from egerds Thanks.
 
Back
Top