Place Null Value in ComboBox

M

Mike C.

Hello.

I'm pretty new to VBA. I have line of code that makes cboBox2 enabled if
cboBox1 value is "Y', and disables cboBox2 if cboBox1 value is "N".

Private Sub InvitetoClassifiedBriefing_Change()
If cboBox1 = "N" Then
cboBox2.Enabled = False
Else
cboBox2.Enabled = True
End If
End Sub


What is the syntax if I want cboBox2 to be diabled and have its value be
Null if cboBox1 = "N"?

Thanks in advance,

m.
 
D

Dirk Goldgar

Mike C. said:
Hello.

I'm pretty new to VBA. I have line of code that makes cboBox2
enabled if cboBox1 value is "Y', and disables cboBox2 if cboBox1
value is "N".

Private Sub InvitetoClassifiedBriefing_Change()
If cboBox1 = "N" Then
cboBox2.Enabled = False
Else
cboBox2.Enabled = True
End If
End Sub


What is the syntax if I want cboBox2 to be diabled and have its value
be Null if cboBox1 = "N"?

Unless I'm overlooking something, it should be as simple as adding one
line to the code you've got:

Private Sub InvitetoClassifiedBriefing_Change()

If cboBox1 = "N" Then
cboBox2.Enabled = False
cboBox2 = Null
Else
cboBox2.Enabled = True
End If

End Sub

I'd be wary of using the Change event of a control for this kind of
thing, though. The AfterUpdate event is usually a better choice. Of
course, I don't know the details of your application.
 

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

Top