calculated date

awake2424

Registered User.
Local time
Today, 03:17
Joined
Oct 31, 2007
Messages
479
I am having trouble with a VBA calculation that if a sample is recieved after 12:00 (noon), then +1 day is added to Date_received. If the sample is received before 12 (noon), then Date_Received is unchanged or the original date. The code below seems to do the first part, but not the second and I am unsure what to do. Thanks.

Code:
 If Me.Test = "LR" And Me.Time_Received > #12:00:00 PM# Then
           Me.Date_Received = [Date_Received] + 1
End If
 
try dropping the PM

Me.Time_Received > #12:00:00#
 
I tried that and it doesn't seem to change anything.

Code:
 If Me.Test = "LR" And Me.Time_Received > #12:00:00 PM# Then
   Me.Date_Received = [Date_Received] + 1
End If

Do I need to have a condition that if the sample is received before noon then the original date is used?

For example,

Time_Received = 10:00 AM and Test = LR so the Date_Received is 7/28/2014

Time_Received = 12:30 PM and Test = LR so the Date_Received is 7/29/2014

Thanks.
 
you could try

Code:
Me.Date_Received = dateadd("d",-(Me.Test = "LR" And Me.Time_Received > 0.5),Date_Received)

It may be that the context is not correct, so what is me.Date_Received? is it a control on a form?

And what is [Date_Received]?
 

Users who are viewing this thread

Back
Top Bottom