Steve,
I have created new table, Quey and Form as you described-- "tblAppointment",
"qryAppointment" and "frmAppointment"
The field names are as follows:
AppointmentDate Date/Time
AppoiuntmentTime Text (Lookup with row source as
"06:00";"06:30";"07:00";"07:30")
AppointmentDuration Number
In the query I cut and pasted your SQL statement SELECT
[tblAppointments].AppointmentDate, [tblAppointments].AppointmentTime,
[tblAppointments].AppointmentDuration,
DateAdd("n",[AppointmentDuration],[AppointmentDate]+[AppointmentTime]) AS
CompletionTime
FROM tblAppointments
ORDER BY [tblAppointments].AppointmentDate, [tblAppointments].AppointmentTime;
The form I have based all controls on the query directly from the field list.
I get #Error in "CompletionTime"
You stated that "AppointmentTime" was a Date/Time, but when I use lookup
wizard to create the dropdown list with row source as
"06:00";"06:30";"07:00";"07:30" it converts to text, is this were I am going
wrong.
Thanking You
Bazmac
Steve Sanford said:
I'm not sure what the question is.
What are the field names and types in your table???
What is the row source type and the row source of the combo box?
The form I created calculates correctly. The combo box is a value list that
I typed in:
8:00;8:30;9:00;13:00
When I change the date, time or the duration, the completion time calculates
correctly.
Maybe give more details??
HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)
:
Steve & John,
Thankyou for your replies, I have tried both methods, with John's I get
12:00 regardless of the "Duration" input, Steve's method works fine provided
that I set the "AppointmentTime" format to short or Medium time.
Is it possible to use a dropdown with the entry the same as short or long
format
Example 06:00 AM for Medium Time or 17:00 for Short Time
I would prefer to use a dropdown in preference to manually entering the time.
Thanking you
Bazmac
:
Since my previous reply I have restructured the syntax as Steve suggested
this works fine for adding hours to todays date, but this is not what I am
trying to achieve which is to add:
"Appointment_Time" to "Duration" to = "Completion_Time"
("Duration" being the amount of time allocated to each appointment)
Does this require a calculation or is there another function available.
The object of the continuous form allows me to manually enter a date against
each appointment, as "Appointment_Date" in the record source query is set to
ascending the contiuous form is sorted into date order after a refresh, the
next step is to set start time and end time against each appointment, then
after a second refresh the form would then display all appointments in date
and time order.
Reread Steve's suggestion, and the Help topic for DateAdd.
The function will allow you to add any time interval from seconds to years -
*YOUR CHOICE*.
If you have a DateTime field (not a combo box, not a screen display, but a
*field in your table*) named AppointmentTime, and a Number field (ditto) named
Duration, the expression
DateAdd("n", [AppointmentTime], [Duration])
will return a Date/Time value which can be displayed as, or assigned to,
Completion_Time.