DTPicker: Incrementing Time Value

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!
 
T

theDBguy

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...
 
J

John W. Vinson

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.
 
K

KARL DEWEY

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")
 
J

John W. Vinson

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!
 
T

theDBguy

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.
 
J

John W. Vinson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top