Change label caption dynamically

pauld118

Registered User.
Local time
Yesterday, 22:27
Joined
Jun 17, 2011
Messages
21
Hello,

I have a label that is associated to a combo box that shows names of facilities. This combo box is on the header of a form (cmbName). The label (label240) is on the detail of the form.

What I would like to do is that when I click a facility name in the combo box (which has a drop down list), the caption of the label changes to the name of the facility selected. I am using access 2007. Any ideas??? I guess that some VBA must be included. :confused::confused::confused:
 
Something like (in the After_Update event of cmbName)...

If Me.cmbName = "Something" Then
Me.label240.Caption = "Something"
Else
Me.lable240.Caption = "Something else"
End If
 
Or, if the name of the facility is the bound column of the Combobox,

Me.label240.Caption = cmbName

in both the cmbName_AfterUpdate and Form_Current events.

Linq ;0)>
 
Thank you both! Now how can I set an standar caption on that label. like when nothing is clicked on the cmb box, the label says Facility Name??

Thanks in advance!

Paul
 
In the On_Current event I would put...

Me.label240.Caption = "Facility Name"

OR did you want it to be dynamic?
 
Thanks Gina!

Although your code work I used missing's code because does it dynamically. The issue that I have now is that the label only shows the bound column. The combo box has the facility name and the state where is located.

I would like to change the label like something like this : facility name, state (this data comes from the combo box. Any ideas???

and yes I'd like it dynamically
 
If the first column in the cbo is the facility name and the second column is the state field
Code:
Me.label240.Caption = Me.cmbName & " " & Me.cmbName.Column(1)
As to how to assign a Caption until something is selected from the Combobox, simply select the Label and go to the Properties Box and fill in the Caption Property with Facility Name!

Linq ;0>
 

Users who are viewing this thread

Back
Top Bottom