table properties

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In defining queries and such, I like to use consistent table aliases and
would like to store that alias with the table so it can be read from code. I
couldn't find a place to store it with the table. I tried

field.TableSource.Description

....Hoping to put the alias in the description property. Didn't fly. Any
suggestions?
 
smk23 said:
In defining queries and such, I like to use consistent table aliases and
would like to store that alias with the table so it can be read from code. I
couldn't find a place to store it with the table. I tried

field.TableSource.Description

...Hoping to put the alias in the description property. Didn't fly. Any
suggestions?


The description (along with some others) are Access custom
properties, not Jet built-in properties. Like all custom
properties, they must be created before they can be used.
As long as you're at it, why not create on that's not going
to be used for anything else.

Dim db As Database
Dim tdf As TableDef
Dim prp As Property

Set db = CurrentDb()
Set tdf = db.TableDefs("tablename")
Set prp = tdf.CreateProperty("MyAlias", dbText, "alias")
tdf.Properties.Append prp

Set prp = Nothing
Set tdf = Nothing
Set db = Nothing

you can then refer to the custom property this way:

CurrentDb.TableDefs!tablename.Properties!MyAlias
 
There's a side-effect of using the Description property that you may not be
aware of.

When you create a form based on this table, Access copies any Description
from field in the table into the Status Bar Text property of the control on
your form. Showing your alias for every field to the user as they move from
control to control may not be the best idea.
 
Back
Top