Customize field labels on a Form

P

Pat Dools

Is it possible to set the label of a field programmatically in Access 2003?
I am building a Baseball statistics database and would like the label of my
'Opponent Score' (Number) field to take on the value of the 'Opponent Name'
(Text) field. Is this possible?
 
J

JamesDeckert

your code line will look something like
Me.lblTemp.Caption = Me.txtTemp.Value

Depending on where txtTemp is populated, will depend on where you need to
put the code (what event).
 
P

Pat Dools

Hi James,

Do you happen to know of a way to use a variation of the code below to
capture the 'Unbound' column of a Combo Box? I have a combo box that is set
to store a team number, but display the team's name on the Form. I want the
code below to be able to grab the unbound column (but displayed on form) and
make the label of another field on the form to take on that value. Is it
possible to use the unbound column of a combo box in this fashion?
 
J

John W. Vinson

Hi James,

Do you happen to know of a way to use a variation of the code below to
capture the 'Unbound' column of a Combo Box? I have a combo box that is set
to store a team number, but display the team's name on the Form. I want the
code below to be able to grab the unbound column (but displayed on form) and
make the label of another field on the form to take on that value. Is it
possible to use the unbound column of a combo box in this fashion?

A Combo Box has a Column property: it's a zero based number, the position of
the field in the combo's Rowsource.

That is, if a Combo is based on a query with five fields, and its ColumnCount
is 5, you can refer to the fifth field in the query (whether it's the bound
column or an unbound one) with

=comboboxname.Column(4)


John W. Vinson [MVP]
 
P

Pat Dools

Hi John,

A follow-up question. Is there a way to automatically re-size the field
label that I am now successfully populating to the value of the combo box to
enlarge or shrink to the size of the team name that shows in the field label
now?
 
J

John W. Vinson

A follow-up question. Is there a way to automatically re-size the field
label that I am now successfully populating to the value of the combo box to
enlarge or shrink to the size of the team name that shows in the field label
now?

Not at all easily. Since different fonts have different sizes - even if they
are all (say) 9 point - it can be a real challenge to figure out how many
twips wide a textbox must be to contain a particular text string. I'd just
make the label or textbox big enough for the longest team name.

John W. Vinson [MVP]
 
P

Pat Dools

Thanks, John!
--
Pat Dools


John W. Vinson said:
Not at all easily. Since different fonts have different sizes - even if they
are all (say) 9 point - it can be a real challenge to figure out how many
twips wide a textbox must be to contain a particular text string. I'd just
make the label or textbox big enough for the longest team name.

John W. Vinson [MVP]
 
Top