Time

  • Thread starter Thread starter Cadburys
  • Start date Start date
C

Cadburys

Hi

I would really appreciate some help with this. My db is used to track jobs.
We have different rules of how long we have to complete a job.

My problem is that I just cant seem to figure out how to evaluate when the
job has arrived.

I would like my code to be something like this:

If [fldClient] = "Company1" and [fldPriority] = Normal and [fldTimeRec]
"Between" 07:00 and 19:00 Then
[fldDeadlineTime] = DateAdd("n", 240, [fldTimeRec])
EndIf

The problem is that my [fldTimeRec] is a short date format and there does
not seem to be a Between....And equivilent when coding?

Please could someone give me some guidance ......

Thanks
Nicky
 
If [fldClient] = "Company1" and [fldPriority] = Normal and _
[fldTimeRec] >= #07:00# and [fldTimeRec] <= #19:00# Then

[fldDeadlineTime] = DateAdd("n", 240, [fldTimeRec])

End If

I'm assuming Normal is a numeric variable or constant that's been defined
somewhere else. If it's actually supposed to be the word Normal, you'll need


If [fldClient] = "Company1" and [fldPriority] = "Normal" and _
[fldTimeRec] >= #07:00# and [fldTimeRec] <= #19:00# Then

[fldDeadlineTime] = DateAdd("n", 240, [fldTimeRec])

End If
 
As expected, Doug gave you the correct answer. Additionally, there is no
BETWEEN in VBA. It would have been nice had they included such a function,
but because they did not and it is very convenient to such a function to
reduce code strokes and (IMHO) make the code read more clearly, here is one I
use a lot. Put it in a Standard Module. I have a module named modUtilities
that contains a lot of useful generic functions:

Public Function IsBetween(varCheckVal As Variant, varLowVal As Variant,
varHighVal As Variant) As Boolean
IsBetween = varCheckVal >= varLowVal And varCheckVal <= varHighVal
End Function

Now, using Doug's example, it would look like this:

If [fldClient] = "Company1" and [fldPriority] = Normal and _
IsBetween([fldTimeRec, #7:00#, #19:00#) Then
[fldDeadlineTime] = DateAdd("n", 240, [fldTimeRec])
End If
 
Back
Top