If specific values then...

adh123

Registered User.
Local time
Today, 19:59
Joined
Jan 14, 2015
Messages
77
Hopefully a simple problem, struggling to find a suitable solution!

I have a textbox on a form which requires a date input in most scenarios and the code below has been working nicely so far (it's part of a number of ifs upon a button being clicked hence elseif

Code:
    ElseIf Me.txte_date_due.Value & "" = "" And Me.cmbStatus.Value <> "11" Then
    Me.txte_date_due.SetFocus
    MsgBox "'Date due' is a mandatory field", vbOKOnly, "required field"
    Exit Sub

I now need to update this to include a second cmbstatusvalue of "12" as well as "11" to be excluded.

Any suggestions?
 
This could be done just by adding in another and statement:

Code:
ElseIf Me.txte_date_due.Value & "" = "" And Me.cmbStatus <> "11" And Me.cmbStatus <> "12" Then

    Me.txte_date_due.SetFocus
    MsgBox "'Date due' is a mandatory field", vbOKOnly, "required field"
    Exit Sub

If it is likely that you are going to start excluding further values in the future you may want to look at using a case statement.
 
I tried or, but not and!

Thanks, simple and works :)

It should not get more complicated than that but thanks for pointing me in the right direction if it does!
 

Users who are viewing this thread

Back
Top Bottom