Date and Time

R

RAM

I have three controls on a form (Appoinment Length, Appontment Time and
Appointment End Time). The appointment time is set to Date/Time (Medium
Time) and appointment length is set to Number (Field Size Double and Format
Standard). I would like to add the appointment length to the appointment
time and have an appointment end time.

Thanks in advance
 
F

fredg

I have three controls on a form (Appoinment Length, Appontment Time and
Appointment End Time). The appointment time is set to Date/Time (Medium
Time) and appointment length is set to Number (Field Size Double and Format
Standard). I would like to add the appointment length to the appointment
time and have an appointment end time.

Thanks in advance

This is very easy to do in a query, on a form, or in a report.

As long as you already have the StartTime and the TimeLength stored in
a table, you only need calculate the End Time.

I'll assume the Time Length is in minutes.
In a query...
EndTime:DateAdd("n",[TimeLength],[StartTime])

In a form or report, using an Unbound control....
=DateAdd("n",[TimeLength],[StartTime])

It cannot not be done in a table and there is no need to store this
calculated data. Any time you need the EndTime, simply recalculate it,
as above.
 
J

John W. Vinson

I have three controls on a form (Appoinment Length, Appontment Time and
Appointment End Time). The appointment time is set to Date/Time (Medium
Time) and appointment length is set to Number (Field Size Double and Format
Standard). I would like to add the appointment length to the appointment
time and have an appointment end time.

Thanks in advance

Only two of these fields should even exist in your table: Appointment Time and
your choice of the other two. After all, once you know the appointment time
and either the length or the end time, you can easily calculate the other.

What I'd recommend - especially if you have a fixed set of appointment
lengths, e.g. 30 minutes, 45 minutes, 1 hour - is use a Long Integer (not
Double) appointment length field stored in your table; use a Combo Box on the
form selecting 30, 45, 60, 90 etc. You could then have an (unbound) textbox on
the form with its control source set to

=DateAdd("n", [cboAppointmentLength], [txtAppointmentTime])

to dynamically calculate the end time. You can use the same or similar
expression any other place that the end time is needed, without storing the
end time anywhere.
 

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

Top