change label caption during run time

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

Guest

Hi all,
Can someone please tell me how can I change a label's caption during
runtime?
say, I have combobox and buttonA in formA. When ButtonA is pressed, formB
will load, labelA in formB needs to have the caption of text on combox from
formA.


Thanks,
 
Hi, Jeff.

All you need is to set the Caption property of the control with the right
syntax. There are multiple ways to do it, but one way is in the OnClick
procedure of your button:

DoCmd.OpenForm "YourFormName"
Forms!YourFormName!YourLabel.Caption = Me!YourComboBox

The above code assumes that the text that is *displayed* in the combo box is
its value, which depends on the Bound Column. If the text is actually the
2nd column, refer to it with the Column property. The second column has
index 1.

DoCmd.OpenForm "YourFormName"
Forms!YourFormName!YourLabel.Caption = Me!YourComboBox.Column(1)

Hope that helps.
Sprinks
 
Back
Top