How to reference an empty combobox

C

cp2599

My combobox is empty, but my code is not picking that up. I've tried
the following statements and none seem to work. Any suggestions?

If Nz(Me.cboSearchArea,0) = 0 then If Nz
(Me.cboSearchArea.Value, 0) = 0 then

If Me.cboSearchArea = "" then If Me.cboSearchArea.Value
= "" then

If Me.cboSearchArea = 0 then If Me.cboSearchArea.Value
= 0 then

If Me.cboSearchArea = " " then If Me.cboSearchArea.Value
= " " then

I'm having the same problem with a numeric field as well.
 
A

Arvin Meyer MVP

How about:

If Len(Me.cboSearchArea & vbNullString) = 0 Then

That checks the length of the data in combo, whether Null or Empty, and if
it = zero, then ...
 
J

Jeanette Cunningham

Where are you putting this code?
If you are using the before update event of the combo, you will need to use
its text property.

If Len(Me.cboSearchArea.Text) = 0 Then
'code
Else
'other code
End If


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
C

cp2599

Where are you putting this code?
If you are using the before update event of the combo, you will need to use
its text property.

If Len(Me.cboSearchArea.Text) = 0 Then
    'code
Else
    'other code
End If

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia











- Show quoted text -

Thank you Jeanette. I moved my code into the cmd button and it works.
 
C

cp2599

How about:

If Len(Me.cboSearchArea & vbNullString) = 0 Then

That checks the length of the data in combo, whether Null or Empty, and if
it = zero, then ...
--
Arvin Meyer, MCP, MVPhttp://www.datastrat.comhttp://www.mvps.org/accesshttp://www.accessmvp.com











- Show quoted text -

Thank you Arvin. I will hang onto this code for another time. I was
referencing other combo boxes that didn't have focus so I moved the
code to the command button and it worked.
 
A

Arvin Meyer MVP

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