Label Reference to Column

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

Guest

Hi,

How do I give a Label in a report the name of say, the first column in a
table? It the name of the column change, the name of the label in the report
must also change.

Thanks!
 
Rudi, this is not the right way to design a database, and will ultimately be
a fruitless exercise.

If the names are constantly changes, columns are being added, removed,
altered, or rearranged, data types are unstable, formatting is inconsistent,
there is no way to build a reliable report on this.

Particularly, you cannot dynamically add more controls to the report at
runtime. To provide an unlimited number of each conceivable type of control
at design time is impractical.

You therefore need to take a fresh approach to the problem, and build a
stable data structure, with relationships to handle the many possible
related items instead of trying to modify the column count and types.

It is possible to save the report with no RecordSource, and programmatically
assign one in the Open event of the report, looping through the existing
controls to set their Control Source, Format, Left, Right, and Visible
properties, along with the Caption of the labels. Occassionally this
approach is justified for a report fed by a crosstab query, where a known
limited number of columns must be handled. You need to be comfortable with
both VBA (to programmatically handle the assignments) and SQL (particularly
the PIVOT clause of the crosstab).
 
My database has a list of default projects to choose from. There is however,
another form which can change a certain project name. I have already
configured my database to change this project name everywhere if I change the
project name on this form. The form will always be regenerated after I have
changed a project name, but I don't want to manually change the label each
time I change the project name, but would like the report to do this
automatically.
 
So the project name needs to be stored in a field (probably in a lookup
table). The project name must not be the field name.
 
Back
Top