Due Dates and Option Groups

W

Webb

Hello;

I am working on a Contact database to track psychiatric appointmets. I am
new to this, so I am just learning and I need some help. I have a subform
which has the following fields

DOC#
Appointment Date
Appointment Time
Return to Clinic

I would like to have an Option Group which would calculate the following
options from the Appointment Date field and return a date automatically in
the Return to Clinic field.

Options would be 1 wk
2 wks
3 wks
1 mo
2 mo
3 mo

I used the Option Group Wizard, which allows me to enter in the above
options and it automatically places 1, 2, 3, 4, 5, 6 as the value for each.
It asks me if I want to store the value in a field, and I chose the Return
to Clinic Field. Then I right click on one of the option buttons and try to
put in the DateAdd function where it shows the value: =DateAdd("w", 1,
[Appointment Date]), but I think I'm doing something wrong, or I'm not
putting it in the right spot or something because it returns a date of
12/31/1899, when I choose the first option. then when I choose each
corresponding option, it adds 1 one day to it (1/1/1900, 1/2/1900, ect.

Can someone help me figure it out, or tell me what I'm doing incorrectly?

Any help is appreciated.

LaDonna
 
D

Duane Hookom

If you don't want to store the 1,2,3,4,... then don't set its control
source to anything. Set the value of each option to the number of weeks to
add to the Appointment Date. 1,2,3,4,8,10,...

Use the after update event of the option group with code like:

Me.txtReturnToClinic = DateAdd("ww", Me.ogrpWeeksOut, Me.txtAppointmentDate

This assumes you have given descriptive names to your controls.
 
K

Klatuu

Duane has given you the correct answer; however, note that in your original
code you have only one "w" as the first argument in your DateAdd() function.
This will add the day of the week, not the number of weeks. For the number
of weeks, you need "ww", which you will see in his code.
 
W

Webb

Thank you for your help. I finally got it. But is the only way I got it to
work. Is there anything wrong with this that I should worry about later?

LaDonna

If Me.Return_To_Clinic= 1 Then RTC_DUE = DateAdd("ww", 1,
[Appointment_Date])


"Duane Hookom" <DuaneAtNoSpanHookomDotNet> wrote in message
If you don't want to store the 1,2,3,4,... then don't set its control
source to anything. Set the value of each option to the number of weeks to
add to the Appointment Date. 1,2,3,4,8,10,...

Use the after update event of the option group with code like:

Me.txtReturnToClinic = DateAdd("ww", Me.ogrpWeeksOut, Me.txtAppointmentDate

This assumes you have given descriptive names to your controls.
 
K

Klatuu

The logic looks just fine. I would suggest three things, just as a matter of
style:
1. If [Appointment_Date] is a control on your form, then it is always best
to reference the form. That way, Access will not be confused as to what
object it belongs to. Also, when others read your code, it is clear where
the object is.
2. What does 1 mean? If you use contstants to give a value a meaningful
name, it is clear to others who have to read your code what you are testing
for. I don't know what 1 is, but for example purposes, I will just use
conFollowUp. You would dim it like this:

Const conFollowUp As Integer = 1

3. Your code is syntactically correct, but IMHO, that style of code is not
as easy to read as always using an If/End If structure. I would code it like
this:

If Me.Return_To_Clinic = conFollowUp Then
RTC_DUE = DateAdd("ww", 1, Me.[Appointment_Date])
End If


Webb said:
Thank you for your help. I finally got it. But is the only way I got it to
work. Is there anything wrong with this that I should worry about later?

LaDonna

If Me.Return_To_Clinic= 1 Then RTC_DUE = DateAdd("ww", 1,
[Appointment_Date])


"Duane Hookom" <DuaneAtNoSpanHookomDotNet> wrote in message
If you don't want to store the 1,2,3,4,... then don't set its control
source to anything. Set the value of each option to the number of weeks to
add to the Appointment Date. 1,2,3,4,8,10,...

Use the after update event of the option group with code like:

Me.txtReturnToClinic = DateAdd("ww", Me.ogrpWeeksOut, Me.txtAppointmentDate

This assumes you have given descriptive names to your controls.
--
Duane Hookom
MS Access MVP


Webb said:
Hello;

I am working on a Contact database to track psychiatric appointmets. I am
new to this, so I am just learning and I need some help. I have a subform
which has the following fields

DOC#
Appointment Date
Appointment Time
Return to Clinic

I would like to have an Option Group which would calculate the following
options from the Appointment Date field and return a date automatically in
the Return to Clinic field.

Options would be 1 wk
2 wks
3 wks
1 mo
2 mo
3 mo

I used the Option Group Wizard, which allows me to enter in the above
options and it automatically places 1, 2, 3, 4, 5, 6 as the value for
each. It asks me if I want to store the value in a field, and I chose the
Return to Clinic Field. Then I right click on one of the option buttons
and try to put in the DateAdd function where it shows the value:
=DateAdd("w", 1, [Appointment Date]), but I think I'm doing something
wrong, or I'm not putting it in the right spot or something because it
returns a date of 12/31/1899, when I choose the first option. then when I
choose each corresponding option, it adds 1 one day to it (1/1/1900,
1/2/1900, ect.

Can someone help me figure it out, or tell me what I'm doing incorrectly?

Any help is appreciated.

LaDonna
 
D

Duane Hookom

Klatuu,
Great reply!


--
Duane Hookom
MS Access MVP

Klatuu said:
The logic looks just fine. I would suggest three things, just as a matter
of
style:
1. If [Appointment_Date] is a control on your form, then it is always
best
to reference the form. That way, Access will not be confused as to what
object it belongs to. Also, when others read your code, it is clear where
the object is.
2. What does 1 mean? If you use contstants to give a value a meaningful
name, it is clear to others who have to read your code what you are
testing
for. I don't know what 1 is, but for example purposes, I will just use
conFollowUp. You would dim it like this:

Const conFollowUp As Integer = 1

3. Your code is syntactically correct, but IMHO, that style of code is not
as easy to read as always using an If/End If structure. I would code it
like
this:

If Me.Return_To_Clinic = conFollowUp Then
RTC_DUE = DateAdd("ww", 1, Me.[Appointment_Date])
End If


Webb said:
Thank you for your help. I finally got it. But is the only way I got it
to
work. Is there anything wrong with this that I should worry about later?

LaDonna

If Me.Return_To_Clinic= 1 Then RTC_DUE = DateAdd("ww", 1,
[Appointment_Date])


"Duane Hookom" <DuaneAtNoSpanHookomDotNet> wrote in message
If you don't want to store the 1,2,3,4,... then don't set its control
source to anything. Set the value of each option to the number of weeks
to
add to the Appointment Date. 1,2,3,4,8,10,...

Use the after update event of the option group with code like:

Me.txtReturnToClinic = DateAdd("ww", Me.ogrpWeeksOut,
Me.txtAppointmentDate

This assumes you have given descriptive names to your controls.
--
Duane Hookom
MS Access MVP


Webb said:
Hello;

I am working on a Contact database to track psychiatric appointmets. I
am
new to this, so I am just learning and I need some help. I have a
subform
which has the following fields

DOC#
Appointment Date
Appointment Time
Return to Clinic

I would like to have an Option Group which would calculate the
following
options from the Appointment Date field and return a date automatically
in
the Return to Clinic field.

Options would be 1 wk
2 wks
3 wks
1 mo
2 mo
3 mo

I used the Option Group Wizard, which allows me to enter in the above
options and it automatically places 1, 2, 3, 4, 5, 6 as the value for
each. It asks me if I want to store the value in a field, and I chose
the
Return to Clinic Field. Then I right click on one of the option
buttons
and try to put in the DateAdd function where it shows the value:
=DateAdd("w", 1, [Appointment Date]), but I think I'm doing something
wrong, or I'm not putting it in the right spot or something because it
returns a date of 12/31/1899, when I choose the first option. then
when I
choose each corresponding option, it adds 1 one day to it (1/1/1900,
1/2/1900, ect.

Can someone help me figure it out, or tell me what I'm doing
incorrectly?

Any help is appreciated.

LaDonna
 
K

Klatuu

Thank you, Duane
I consider it to be a high honor to be complimented by an MVP
(hope to attain that lofty goal someday)

Duane Hookom said:
Klatuu,
Great reply!


--
Duane Hookom
MS Access MVP

Klatuu said:
The logic looks just fine. I would suggest three things, just as a matter
of
style:
1. If [Appointment_Date] is a control on your form, then it is always
best
to reference the form. That way, Access will not be confused as to what
object it belongs to. Also, when others read your code, it is clear where
the object is.
2. What does 1 mean? If you use contstants to give a value a meaningful
name, it is clear to others who have to read your code what you are
testing
for. I don't know what 1 is, but for example purposes, I will just use
conFollowUp. You would dim it like this:

Const conFollowUp As Integer = 1

3. Your code is syntactically correct, but IMHO, that style of code is not
as easy to read as always using an If/End If structure. I would code it
like
this:

If Me.Return_To_Clinic = conFollowUp Then
RTC_DUE = DateAdd("ww", 1, Me.[Appointment_Date])
End If


Webb said:
Thank you for your help. I finally got it. But is the only way I got it
to
work. Is there anything wrong with this that I should worry about later?

LaDonna

If Me.Return_To_Clinic= 1 Then RTC_DUE = DateAdd("ww", 1,
[Appointment_Date])


"Duane Hookom" <DuaneAtNoSpanHookomDotNet> wrote in message
If you don't want to store the 1,2,3,4,... then don't set its control
source to anything. Set the value of each option to the number of weeks
to
add to the Appointment Date. 1,2,3,4,8,10,...

Use the after update event of the option group with code like:

Me.txtReturnToClinic = DateAdd("ww", Me.ogrpWeeksOut,
Me.txtAppointmentDate

This assumes you have given descriptive names to your controls.
--
Duane Hookom
MS Access MVP


Hello;

I am working on a Contact database to track psychiatric appointmets. I
am
new to this, so I am just learning and I need some help. I have a
subform
which has the following fields

DOC#
Appointment Date
Appointment Time
Return to Clinic

I would like to have an Option Group which would calculate the
following
options from the Appointment Date field and return a date automatically
in
the Return to Clinic field.

Options would be 1 wk
2 wks
3 wks
1 mo
2 mo
3 mo

I used the Option Group Wizard, which allows me to enter in the above
options and it automatically places 1, 2, 3, 4, 5, 6 as the value for
each. It asks me if I want to store the value in a field, and I chose
the
Return to Clinic Field. Then I right click on one of the option
buttons
and try to put in the DateAdd function where it shows the value:
=DateAdd("w", 1, [Appointment Date]), but I think I'm doing something
wrong, or I'm not putting it in the right spot or something because it
returns a date of 12/31/1899, when I choose the first option. then
when I
choose each corresponding option, it adds 1 one day to it (1/1/1900,
1/2/1900, ect.

Can someone help me figure it out, or tell me what I'm doing
incorrectly?

Any help is appreciated.

LaDonna
 

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