A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Convert to VBA code?



 
 
Thread Tools Display Modes
  #1  
Old March 22nd, 2010, 02:20 PM posted to microsoft.public.access.forms
Darrell Childress[_3_]
external usenet poster
 
Posts: 32
Default 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  
Old March 22nd, 2010, 02:43 PM posted to microsoft.public.access.forms
Tom van Stiphout[_2_]
external usenet poster
 
Posts: 1,653
Default 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  
Old March 22nd, 2010, 03:08 PM posted to microsoft.public.access.forms
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default 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  
Old March 22nd, 2010, 03:14 PM posted to microsoft.public.access.forms
Darrell Childress[_3_]
external usenet poster
 
Posts: 32
Default 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  
Old March 22nd, 2010, 03:17 PM posted to microsoft.public.access.forms
Darrell Childress[_3_]
external usenet poster
 
Posts: 32
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:25 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.