PC Review


Reply
Thread Tools Rate Thread

Add day to current Day.

 
 
Antonio
Guest
Posts: n/a
 
      17th Sep 2003
This question is in reference to a September 12 posting. I
was given two options by two different people (thank you
so very much) but I cant seem to get either of them to
work. I am almost positive it isn't with the code or
expression, rather with my implementing the code or
expression. I was wondering if I could get
clarification/guidance on how to implement the code and/or
the expression into the form/table properties. (while I am
being so honest, as far as the code goes, I know little
else other than launching the VB Editor window and doin a
copy and paste of what is shown to me...otherwise, I am a
bit lost.) Here is a recap of my initial question (with a
few more specifics)

I have a form that has a date field
entitled "ToBePulledOn". As it is now, the current date is
the default value - Date(). I am looking for an expression
or code that makes the default value for
the "ToBePulledOn" field between the hours of 12:00 AM and
10:29 PM the current date. From 10:30 PM to 11:59 PM I
would like the date field to equal the following days
date. ie Date() + 1.

I received two responses. One containing code and one
containing an expression.
Honestly speaking, I am not entirely sure of how to
implement the code given in a forms "Before Update" event.
When I tried to enter the expression into the default
value I received an error each time I tried to save. The
error message stated there was a format conflict of some
sort and it prevented me from proceeding any further.
Can anyone help?
Here are copies of both the Code and Expression that were
given to me.

>In the Before Update event of the form try something like
>this:


>Dim dteCurrentTime As Date
>dteCurrentTime = Time
>If dteCurrentTime >= #4:00:00 AM# And dteCurrentTime
> <#10:30:00 PM# Then
> 'Do Nothing
>ElseIf dteCurrentTime >= #10:30:00 PM# Then
> txtField2 = DateAdd("d", 1, txtField2)
>Else
> MsgBox "What are you doing here at " & Time & "?",
>vbOKOnly + vbExclamation
>End If


Here is a copy of the expression that was given to me.

>I think this will do that:


>dtfield - (DateDiff("n", CLng(dtfield), dtfield )
> >=22.5*60)




 
Reply With Quote
 
 
 
 
Rick Brandt
Guest
Posts: n/a
 
      17th Sep 2003
"Antonio" <(E-Mail Removed)> wrote in message
news:088501c37cd4$6ed3c870$(E-Mail Removed)...
> This question is in reference to a September 12 posting. I
> was given two options by two different people (thank you
> so very much) but I cant seem to get either of them to
> work. I am almost positive it isn't with the code or
> expression, rather with my implementing the code or
> expression. I was wondering if I could get
> clarification/guidance on how to implement the code and/or
> the expression into the form/table properties. (while I am
> being so honest, as far as the code goes, I know little
> else other than launching the VB Editor window and doin a
> copy and paste of what is shown to me...otherwise, I am a
> bit lost.) Here is a recap of my initial question (with a
> few more specifics)
>
> I have a form that has a date field
> entitled "ToBePulledOn". As it is now, the current date is
> the default value - Date(). I am looking for an expression
> or code that makes the default value for
> the "ToBePulledOn" field between the hours of 12:00 AM and
> 10:29 PM the current date. From 10:30 PM to 11:59 PM I
> would like the date field to equal the following days
> date. ie Date() + 1.
>
> I received two responses. One containing code and one
> containing an expression.
> Honestly speaking, I am not entirely sure of how to
> implement the code given in a forms "Before Update" event.


The code looks okay to me. Find the BeforeUpdate event of the form in the property
sheet and press on the build [...] button to the right. Choose "Code Builder". This
will take you to the form's code module with the cursor already positioned where you
need to paste that code.


 
Reply With Quote
 
John Spencer (MVP)
Guest
Posts: n/a
 
      18th Sep 2003
Try setting the default to:

Default Value: =Date() - (TimeValue(Now()) >= #10:30:00 PM#)

Antonio wrote:
>
> This question is in reference to a September 12 posting. I
> was given two options by two different people (thank you
> so very much) but I cant seem to get either of them to
> work. I am almost positive it isn't with the code or
> expression, rather with my implementing the code or
> expression. I was wondering if I could get
> clarification/guidance on how to implement the code and/or
> the expression into the form/table properties. (while I am
> being so honest, as far as the code goes, I know little
> else other than launching the VB Editor window and doin a
> copy and paste of what is shown to me...otherwise, I am a
> bit lost.) Here is a recap of my initial question (with a
> few more specifics)
>
> I have a form that has a date field
> entitled "ToBePulledOn". As it is now, the current date is
> the default value - Date(). I am looking for an expression
> or code that makes the default value for
> the "ToBePulledOn" field between the hours of 12:00 AM and
> 10:29 PM the current date. From 10:30 PM to 11:59 PM I
> would like the date field to equal the following days
> date. ie Date() + 1.
>
> I received two responses. One containing code and one
> containing an expression.
> Honestly speaking, I am not entirely sure of how to
> implement the code given in a forms "Before Update" event.
> When I tried to enter the expression into the default
> value I received an error each time I tried to save. The
> error message stated there was a format conflict of some
> sort and it prevented me from proceeding any further.
> Can anyone help?
> Here are copies of both the Code and Expression that were
> given to me.
>
> >In the Before Update event of the form try something like
> >this:

>
> >Dim dteCurrentTime As Date
> >dteCurrentTime = Time
> >If dteCurrentTime >= #4:00:00 AM# And dteCurrentTime
> > <#10:30:00 PM# Then
> > 'Do Nothing
> >ElseIf dteCurrentTime >= #10:30:00 PM# Then
> > txtField2 = DateAdd("d", 1, txtField2)
> >Else
> > MsgBox "What are you doing here at " & Time & "?",
> >vbOKOnly + vbExclamation
> >End If

>
> Here is a copy of the expression that was given to me.
>
> >I think this will do that:

>
> >dtfield - (DateDiff("n", CLng(dtfield), dtfield )
> > >=22.5*60)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
current week, current month, current year joemeshuggah Microsoft Excel Programming 1 14th Oct 2008 06:44 PM
OperationContext.Current or HttpContext.Current in MembershipProvider within WCF Service = null? dgilbert@cragmonttech.com Microsoft C# .NET 4 18th May 2007 05:24 PM
Calculating current investment value, current mortgage balance Scott Meyers Microsoft Excel Worksheet Functions 1 10th Jul 2004 08:13 PM
changing current directory to that of the current open file unnameable Microsoft Excel Programming 2 19th May 2004 11:14 AM
How to change the current thread current culture at run time. Manu Microsoft ASP .NET 1 20th Jul 2003 04:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:34 PM.