Using a variable to represent a combo box

M

mcgj

In my vba code I want to pass a combo box (control) as a variable from one
procedure to another to test weather or not it is blank (null). I cannot
seem to understand how to do this!!! Can some please give me the
kindergarten version of how to do this?
 
G

George Nicholson

Private Sub cboSomeName_GotFocus()
If ControlIsEmpty(Me.cboSomeName) = True Then
'Do this if True
Else
'Do this if False
End If
End Sub

Public Function ControlIsEmpty(ctl as Control) As Boolean
ControlIsEmpty = IsNull(ctl)
'Alternate version:
' ControlIsEmpty = Len(Nz(ctl,"")) = 0
End Function

HTH,
 
Top