select case not working

Fuga

Registered User.
Local time
Today, 12:28
Joined
Feb 28, 2002
Messages
566
I have put the following select case structure as the on current event of a form.

PHP:
Select Case Me.myfield
    
    Case Is < #12/13/02#
    

    
    Case Is >= #12/13/02# <= #2/14/03#
    
    
    Case Is >= #2/15/03#
    

End Select

Now, for some reason, the third case never executes even though the date value of me.myfield is greater than 2003-02-15. The other two cases works just fine. What could be causing this?

Fuga.
 
The second one is causing your problem.

What you have isn't actually a between statement: it is saying all dates after this date OR all dates before this date which would cover the third case.

The trick with SELECT CASE is to put the most likely case near the type and work your way down.


Code:
Select Case Me.myfield

    Case Is >= #2/15/03#
    
    Case Is < #12/13/02#
   
    Case Is >= #12/13/02#, <= #2/14/03#

End Select
 
Try this instead:
Code:
Select Case Me.myfield
  Case Is < #12/13/02#

  Case #12/13/02# To #2/14/03#

  Case Is >#2/14/03#
End Select
HTH
RDH
 

Users who are viewing this thread

Back
Top Bottom