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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top