Adding minutes

B

Bazmac

Hi,

I have read through many posts but cannot achieve my desired result.

I have a contiuous form to sort the current customers into the upcoming
weeks appointments.

I have the following controls "Date", "Appointment_Time" and "Duration" I
then have a textbox "Completion_Time".

In the textbox "Completion_Time" I would like to do the following calculation:

"Appointment_Time" + "Duration" = "Completion_Time"

"Appointment_Time" is a dropdown in the following format 06:30
"Duration" is entered as a whole number ie 60

I have tried =DateAdd("n",[Appointment_Time],[Duration]) but get #Error

Can anyone help.

Thanking you in advance
Bazmac
 
A

Anita Ionzon

Bazmac said:
Hi,

I have read through many posts but cannot achieve my desired result.

I have a contiuous form to sort the current customers into the upcoming
weeks appointments.

I have the following controls "Date", "Appointment_Time" and "Duration" I
then have a textbox "Completion_Time".

In the textbox "Completion_Time" I would like to do the following
calculation:

"Appointment_Time" + "Duration" = "Completion_Time"

"Appointment_Time" is a dropdown in the following format 06:30
"Duration" is entered as a whole number ie 60

I have tried =DateAdd("n",[Appointment_Time],[Duration]) but get #Error

Can anyone help.

Thanking you in advance
Bazmac
 
S

Steve Sanford

Well, first the syntax is wrong. You have two of the arguments swapped. The
syntax is:

DateAdd(interval, number, date)

"number" should be of type Long
"date" should be of type date/time (not a string/text)

Is the row source for the combo box "Appointment_Time" a value list or from
a query/table? If from a table, what is the field type?

HTH
 
B

Bazmac

Steve,

Thank you for ypur reply.

Appointment_Time is a dropdown created with the lookup wizard with values
that I entered.

Bazmac

Steve Sanford said:
Well, first the syntax is wrong. You have two of the arguments swapped. The
syntax is:

DateAdd(interval, number, date)

"number" should be of type Long
"date" should be of type date/time (not a string/text)

Is the row source for the combo box "Appointment_Time" a value list or from
a query/table? If from a table, what is the field type?

HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


Bazmac said:
Hi,

I have read through many posts but cannot achieve my desired result.

I have a contiuous form to sort the current customers into the upcoming
weeks appointments.

I have the following controls "Date", "Appointment_Time" and "Duration" I
then have a textbox "Completion_Time".

In the textbox "Completion_Time" I would like to do the following calculation:

"Appointment_Time" + "Duration" = "Completion_Time"

"Appointment_Time" is a dropdown in the following format 06:30
"Duration" is entered as a whole number ie 60

I have tried =DateAdd("n",[Appointment_Time],[Duration]) but get #Error

Can anyone help.

Thanking you in advance
Bazmac
 
B

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.

Hope this explains what I am trying to achieve.

Bazmac

Bazmac said:
Steve,

Thank you for ypur reply.

Appointment_Time is a dropdown created with the lookup wizard with values
that I entered.

Bazmac

Steve Sanford said:
Well, first the syntax is wrong. You have two of the arguments swapped. The
syntax is:

DateAdd(interval, number, date)

"number" should be of type Long
"date" should be of type date/time (not a string/text)

Is the row source for the combo box "Appointment_Time" a value list or from
a query/table? If from a table, what is the field type?

HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


Bazmac said:
Hi,

I have read through many posts but cannot achieve my desired result.

I have a contiuous form to sort the current customers into the upcoming
weeks appointments.

I have the following controls "Date", "Appointment_Time" and "Duration" I
then have a textbox "Completion_Time".

In the textbox "Completion_Time" I would like to do the following calculation:

"Appointment_Time" + "Duration" = "Completion_Time"

"Appointment_Time" is a dropdown in the following format 06:30
"Duration" is entered as a whole number ie 60

I have tried =DateAdd("n",[Appointment_Time],[Duration]) but get #Error

Can anyone help.

Thanking you in advance
Bazmac
 
S

Steve Sanford

I re-read your first post realized I missed that you have a field named
"DATE". "DATE" is a reserved name and should not be used for object names
(and is not very descriptive - DATE of what??). A better name would be
"AppointmentDate".
------------------------


Here is what I did....

I created a table named "tblAppointments". It has fields:

field field
name type
------------------------------------
ID Autonumber
AppointmentDate Date/Time
AppointmentTime Date/Time
AppointmentDuration Number (Long)


Then I created a query "qryAppointments". Here is the SQL:

SELECT [tblAppointments].AppointmentDate, [tblAppointments].AppointmentTime,
[tblAppointments].AppointmentDuration,
DateAdd("n",[AppointmentDuration],[AppointmentDate]+[AppointmentTime]) AS
CompletionTime
FROM tblAppointments
ORDER BY [tblAppointments].AppointmentDate, [tblAppointments].AppointmentTime;


Note that there is *not* a field in the TABLE for the "CompletionTime".
Since this is calculated, it doesn't need to be stored in the table.


The calculated field in the query is:

CompletionTime:
DateAdd("n",[AppointmentDuration],[AppointmentDate]+[AppointmentTime])


(You have to add the date field to the time field, *then* add the duration
to get the completion time.)



In the form, the query (with your additional fields) would be the
recordsource. The controls on the form would be bound to the fields of the
query. Any changes to the controls is automatically recalculated and
displayed.

HTH

--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


Bazmac said:
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.

Hope this explains what I am trying to achieve.

Bazmac

Bazmac said:
Steve,

Thank you for ypur reply.

Appointment_Time is a dropdown created with the lookup wizard with values
that I entered.

Bazmac

Steve Sanford said:
Well, first the syntax is wrong. You have two of the arguments swapped. The
syntax is:

DateAdd(interval, number, date)

"number" should be of type Long
"date" should be of type date/time (not a string/text)

Is the row source for the combo box "Appointment_Time" a value list or from
a query/table? If from a table, what is the field type?

HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


:

Hi,

I have read through many posts but cannot achieve my desired result.

I have a contiuous form to sort the current customers into the upcoming
weeks appointments.

I have the following controls "Date", "Appointment_Time" and "Duration" I
then have a textbox "Completion_Time".

In the textbox "Completion_Time" I would like to do the following calculation:

"Appointment_Time" + "Duration" = "Completion_Time"

"Appointment_Time" is a dropdown in the following format 06:30
"Duration" is entered as a whole number ie 60

I have tried =DateAdd("n",[Appointment_Time],[Duration]) but get #Error

Can anyone help.

Thanking you in advance
Bazmac
 
J

John W. Vinson

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

Bazmac

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

John W. Vinson said:
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.
 
J

John W. Vinson

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.

You're misunderstanding.

The calculation I posted gives you an *INTEGER NUMBER* - not a date/time. If
you get an integer 3600 (6 hours in minutes), it is equivalent to a date/time
value of #11/8/1909 12:00:00# - 3600 days after the December 30, 1899 zero
point of the date/time value. If you display it with a "hh:nn" format then
yes, you'll get midnight.

I was *not* suggesting that you do so.

I was suggesting that you do NOT use date/time values for durations, but
instead to get the duration *in minutes* (or hours, or whatever time unit you
choose) and manipulate it mathematically.

Date/Time values WILL NOT WORK for storing durations. If you have a duration
summing to 25 hours, it will display as #12/31/1899 01:00:00# - or as 1 hour
if you display it in hh:nn format.
 
S

Steve Sanford

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


Bazmac said:
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

John W. Vinson said:
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.
 
G

GeoffK

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


Bazmac said:
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

John W. Vinson said:
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.
 
B

Bazmac

Steve,

Appologies for the confusion I replied in my collegues log in account
(should'nt let others use your PC).

Bazmac

GeoffK said:
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.)


Bazmac said:
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.
 
J

John W. Vinson

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

Yes. Try converting it back to date/time:

DateAdd("n",[AppointmentDuration], CDate([AppointmentDate] & " " &
[AppointmentTime])) AS
CompletionTime
 
S

Steve Sanford

In the table, for the field "AppointmentTime", I used "DATE/TIME" as the
field type not TEXT.

So you have two choices:

use a conversion function to convert the appointment time from "TEXT" to a
"DATE/TIME" type as in John's post

or

change the field type to "DATE/TIME". (I prefer this option since you are
working with time)


HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


GeoffK said:
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.)


Bazmac said:
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.
 
B

Bazmac

John & Steve,

I have eventually got it.

Thanks for your help it's much appreciated.

Bazmac

Steve Sanford said:
In the table, for the field "AppointmentTime", I used "DATE/TIME" as the
field type not TEXT.

So you have two choices:

use a conversion function to convert the appointment time from "TEXT" to a
"DATE/TIME" type as in John's post

or

change the field type to "DATE/TIME". (I prefer this option since you are
working with time)


HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


GeoffK said:
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.
 

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