testing combo box value

ledgerr.rob

Registered User.
Local time
Yesterday, 22:50
Joined
Jun 3, 2012
Messages
68
Windows vista
Access 2007

I can't seem to figure out how to test a combo box null value.

I try:
Code:
If IsNull(Me.cboManufacturer) Then
    MsgBox ("Please select category")
Else
    DoCmd.OpenReport "rptItemCategory", acViewPreview
End If
This works if the combo box IS NOT NULL, but if null it gives me:

PHP:
Run-time error '3071': This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables.

I then tried:
Code:
If IsNull(Me.cboManufacturer.Column(0)) Then
    MsgBox ("Please select category")
Else
    DoCmd.OpenReport "rptItemCategory", acViewPreview
End If

This works if the combo box IS NULL but if i've made a selection, it still gives me the message box as if i've selected nothing....

any ideas?

Thoughts appreciated,
rob
 
Let's just say that i 'overlooked' something....namely the name of the combo box i pointed the code to...I'm an IDIOT lol

For those of you looking for a solution These are the ones that worked for me. Maybe someone with some more knowledge can say what one the 'correct' way is.

1
Code:
If cboItemCategory.ListIndex = -1 Then
    MsgBox ("Please Select a Category to Process")
Else
    DoCmd.OpenReport "rptItemCategory", acViewPreview
End If

2
Code:
If IsNull(Me.cboItemCategory.Column(0)) Then
    MsgBox ("Please select category")
Else
    DoCmd.OpenReport "rptItemCategory", acViewPreview
End If

I went with option 1 in the end

rob
 

Users who are viewing this thread

Back
Top Bottom