Convert to VBA code?

  • Thread starter Thread starter Darrell Childress
  • Start date Start date
D

Darrell Childress

I originally had a button that, when clicked, would run a macro. I now
need to write the VBA code for that instead, and need help. Here's what
I am trying to accomplish:

My form contains a field called TimeStop which contains Date/Time in the
format of 3/22/10 10:05:06 AM
I need to populate a field called DateStop and the value of that field
will depend on the TIME portion of TimeStop. If TimeStop is between
12:00:00 AM (midnight) and 5:00:00 AM, then I need DateStop to be the
current date - 1. Otherwise, I need it to be the current date.

Here's my stab at it, but I don't know the correct syntax to use

If TimeValue(Me.TimeStop) is between #12:00:00 AM# and #5:00:00 AM" Then
Me.DateStop = Date()-1
Else
Me.DateStop = Date()
End If

Thanks for any help,
Darrell
 
On Mon, 22 Mar 2010 10:20:22 -0400, Darrell Childress

Pretty close.

If TimeValue(Me.TimeStop) < #5:00:00 AM# Then
Me.DateStop = DateAdd("d", -1, Date())
Else
Me.DateStop = Date()
End If

-Tom.
Microsoft Access MVP
 
works great, thanks Tom. I thought I was close.

On Mon, 22 Mar 2010 10:20:22 -0400, Darrell Childress

Pretty close.

If TimeValue(Me.TimeStop)< #5:00:00 AM# Then
Me.DateStop = DateAdd("d", -1, Date())
Else
Me.DateStop = Date()
End If

-Tom.
Microsoft Access MVP
 
Thanks, Daryl. I had just tried Tom's suggestion, which worked. I need
to do this to another macro, and I will try this...I never knew that
existed.
 
Back
Top