If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Convert to VBA code?
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 |
#2
|
|||
|
|||
Convert to VBA code?
On Mon, 22 Mar 2010 10:20:22 -0400, Darrell Childress
wrote: 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 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 |
#3
|
|||
|
|||
Convert to VBA code?
Darrell -
You can use Tools | Macro | Convert Macro to Visual Basic to do this. -- Daryl S "Darrell Childress" wrote: 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 . |
#4
|
|||
|
|||
Convert to VBA code?
works great, thanks Tom. I thought I was close.
On 3/22/10 10:43 AM, Tom van Stiphout wrote: On Mon, 22 Mar 2010 10:20:22 -0400, Darrell Childress wrote: 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 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 |
#5
|
|||
|
|||
Convert to VBA code?
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. On 3/22/10 11:08 AM, Daryl S wrote: Darrell - You can use Tools | Macro | Convert Macro to Visual Basic to do this. |
Thread Tools | |
Display Modes | |
|
|