Place Null Value in ComboBox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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.
 
Back
Top