RKreidler
RKreidler

Reputation: 1

Referencing specific label in Access subform

I have a Form and Subform, similar to a simple order entry system. Everything works fine, except for this. When I enter information on the subform, I would like a certain label to be visible or invisible depending on the name that was selected in a combo box (populated from another table).

Currently the subform AfterUpdate event for the combo box says this:

If cmbMName.Column(2) = True Then
    lblAddMileage.Visible = True
Else
    lblAddMileage.Visible = False
End If

The problem with this is that if there are multiple entries, all lblAddMileage labels (each line) on the subform will be visible or invisible. Is there a way to make only the single entry visible or invisible?

Upvotes: 0

Views: 45

Answers (1)

Olivier Jacot-Descombes
Olivier Jacot-Descombes

Reputation: 112672

Yes, there is a nice workaround. Use a TextBox instead. Set the Control source to ="Label Caption", and the properties Enabled = No and Locked = Yes.

Now, right-click on this textbox and select Conditional Formatting... and add a rule, so that when the condition is met, you set the text color equal to the background color, which makes the label invisible.

This rule is applied to each row individually.

enter image description here

The result looks like this:

enter image description here

Upvotes: 1

Related Questions