time fields

  • Thread starter Thread starter bindurajeesh
  • Start date Start date
B

bindurajeesh

I am comparing two time fields and if they meet certain criteria various
things are done. I am running into a problem because the code thinks that
2:00 PM is greater than 2:30 PM. How can I make code realize that it is less
than?
 
Then something is wrong with the comparison. I get the expected results.

You might consider posting the code you are using.

Is it possible that one value has a date attached to it?

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
 
I have taken data from a recordset and assigned it to a variable which is of
date datatype. snippet of code follows:

Case Is > rs1!los_beg_time And timeout > rs1!los_end_time

where case is is the variable above mentioned (timein) in the immediate view
I do ?format(rs1!los_beg_time, "Short Time") and get 14:00
timein= format(rs1!los_beg_time, "Short Time")
?timein in immediate window gives me 2:00:00 PM
 
in the immediate window this is typed:
?timein>rs1!los_beg_time and timeout>rs1!los_end_time
with the result of false but when it comes to that line in the case select
it treats it as true
I'm confused.
 
You didn't post enough of your code to really see what is happening.

I suspect what you want is not a case statement but an

If
ElseIf
ElseIf
ElseIf
End If

structure. Then you could use this kind of structure.

IF timein=rs1!los_beg_time and timeout=rs1!los_end_time THen
'Do option one
ElseIf timein>rs1!los_beg_time and timeout>rs1!los_end_time Then
'Do Something here
ElseIF timein=rs1!los_beg_time Then
'Do something else
ElseIf timeout=rs1!los_end_time then
'Do a fourth option
End iF

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
 
that fixed the problem although i do not understand why a case select did not
work and a elseif combo did. if you could give me knowledge about this that
would be great. otherwise thanks.

bill
 
Because the Case statement can only check the variable, field, etc that is the
first line of the case

Assume X is an integer that is always greater than 1
Select Case x
Case 1
Case 2
Case 3 and w=12
End Select

3 and W =12 will return 0 and X is by definition never = to 0

The If...elseif...else...End if construct works differently and checks to see
if x = 3 and if W = 12 and will return true or false

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
 
Back
Top