DTPicker: Incrementing Time Value

  • Thread starter Thread starter Brandon P
  • Start date Start date
B

Brandon P

I have a form with the following DTpicker's

InterviewStart (format= "mm/dd/yyyy HH:mm")
InterviewEnd (format= "mm/dd/yyyy HH:mm")

When the user inserts a record, the InterviewStart field updates to Now().

I would like to set the default value of InterviewEnd to be 1.5 hours from
Now(). How does the VBA code look in order to accomplish this?

TIA!
 
Hi Brandon,

You might try something like:

Me.InterviewEnd = DateAdd("h", 1.5, Now())

or

Me.InterviewEnd = DateAdd("h", 1.5, Me.InterviewStart

Hope that helps...
 
I have a form with the following DTpicker's

InterviewStart (format= "mm/dd/yyyy HH:mm")
InterviewEnd (format= "mm/dd/yyyy HH:mm")

When the user inserts a record, the InterviewStart field updates to Now().

I would like to set the default value of InterviewEnd to be 1.5 hours from
Now(). How does the VBA code look in order to accomplish this?

TIA!

I think you'll need to use:

Me!InterviewEnd = DateAdd("n", 90, Me!InterviewStart)

The increment argument to DateAdd needs to be an integer so you can add 90
minutes but not 1.5 hours.
 
InterviewStart (format= "mm/dd/yyyy HH:mm")
InterviewEnd (format= "mm/dd/yyyy HH:mm")
This is wrong as "m" is used for Months and not Minutes.

Correct would be --
InterviewStart (format= "mm/dd/yyyy HH:nn")
InterviewEnd (format= "mm/dd/yyyy HH:nn")
 
This is wrong as "m" is used for Months and not Minutes.

To my moderate surprise, the Format feature is sufficiently context-sensitive
that it interprets the first mm as month and the second as minutes:

?format(now,"mm/dd/yyyy hh:mm")
01/07/2010 16:34


I'd still use n for miNutes and m for Months, though!
 
Thanks for the correction, John.


John W. Vinson said:
I think you'll need to use:

Me!InterviewEnd = DateAdd("n", 90, Me!InterviewStart)

The increment argument to DateAdd needs to be an integer so you can add 90
minutes but not 1.5 hours.
 
On Fri, 8 Jan 2010 13:55:01 -0800, theDBguy <thedbguy(at)gmail(dot)com> wrote:

I remember a very confusing afternoon trying to figure out why my DateAdd
wasn't working. IIRC I asked a question here and someone pointed me the right
direction.
 
Back
Top