If then/ ensure not Null... Help?

morfusaf

Registered User.
Local time
Yesterday, 22:39
Joined
Apr 24, 2012
Messages
78
OK, I have a combo box, when I load the form, its empty... If the member wishes to run a certain report, then they will choose this combo box, and pick a members name... then click the Run Report button. After that it needs to check if the combo box had anything in it... if so then run report accordingly. if not(its null or 0) then i need it to run a msgbox, and setfocus back to the combo box.

Code:
     If cboMemberNameHours.Value = 0 Then
        MsgBox ("You need to enter a member to look up.")
        cboMemberNameHours.SetFocus
    Else
     DoCmd.OpenReport "rptMemberHours", acViewPreview, , "tblPeople.PersonID = " & Me.cboMemberNameHours
    
    End If

What am I doing wrong? This code is on the buttonClick()
 
To test for both Null and a zero length string:

If Len(Me.cboMemberNameHours & vbNullString) = 0 Then
 
Thanks that works... Needed the dang Len(... Duh.
 
No problem. If the value in the combo could actually be zero, you'd want to test for that too; this test wouldn't pick that up.
 

Users who are viewing this thread

Back
Top Bottom