最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Referencing specific label in Access subform - Stack Overflow

programmeradmin0浏览0评论

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?

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?

Share Improve this question asked Feb 21 at 17:47 RKreidlerRKreidler 11 silver badge 1
  • 1 No. Alternative is to use a textbox as a "label" and IIf() expression in textbox displays text or Null depending on condition. – June7 Commented Feb 21 at 18:18
Add a comment  | 

1 Answer 1

Reset to default 1

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.

The result looks like this:

发布评论

评论列表(0)

  1. 暂无评论