VBA Code - ComboBox Mult Selections and Visibility Settings (1 Viewer)

wrand80

New member
Local time
Today, 04:14
Joined
Feb 23, 2018
Messages
1
Hello everyone,
I am currently working on a database that allows users to select categories from a combo box on a form. Users may choose 1 or both options in this combo box.

The fields in the CB are Privacy and Service Level. The way the business owners want the form to work is to have certain fields (like validation) only viewable if Privacy is one of the options selected in the CB.

I currently have the form set on current to:
Private Sub Form_Current()
Val.Visible = False
End Sub

Additionally, on the CB field I have the following set to After Update:
Private Sub RiskCat_AfterUpdate()
If RiskCat.Column(1) = "Privacy" Then
Val.Visible = True
Else
Val.Visible = False
End If
End Sub

That seems to work if only the Privacy option is selected, however if both Privacy and Service Level are selected the validation field is still not visible. I've tried multiple additional Ifs for both fields, but it errors every time.

I'm not very experienced with VBA, and I've been wracking my brain try to figure this out. Could anyone help me out?

Thanks so much in advance!
 

MarkK

bit cruncher
Local time
Today, 01:14
Joined
Mar 17, 2004
Messages
8,179
Welcome to the forum.

The problem I see there is that the change in the visibility of the object "Val" is dependent on the value of RiskCat, but RiskCat might change as the result of two different events...
1) loading a new record in the form (Current event) may change the value of RiskCat
2) user interaction with the RiskCat control (AfterUpdate event) may change the value of RiskCat
You only appear to re-evaluate Val's visibility in the AfterUpdate event, but don't you also need also re-evaluate Val's visibility on Current, based on RiskCat (not just set it to false, as you do)?

But the plot thickens, because this does not seem to be what you are asking about, so I am unsure. I think it would help if you elaborate on this...
I've tried multiple additional Ifs for both fields, but it errors every time.
Can you show what you tried here? I think that might help us understand what you are trying to do.
hope this helps,
Mark
 

Users who are viewing this thread

Top Bottom