Adding months to a date of birth

D

debbiep

I am working in a form. I have a field called Visiting Date and a
field called DOB and a field called Classroom. I am trying to come up
with a formul in the Visiting date that will show if a Child's
Classroom = Bumble Bears, the visiting date needs to tell me the date
on his 15 months, when the Child's Classroom = Doodlebugs, the
visiting date needs to tell me the date on his 33 months. Can anyone
help me. I have such a hard time with IF statements. Your help is
greatly appreciated.
Thank you!
 
D

debbiep

I am working in a form. I have a field called Visiting Date and a
field called DOB and a field called Classroom. I am trying to come up
with a formul in the Visiting date that will show if a Child's
Classroom = Bumble Bears, the visiting date needs to tell me the date
on his 15 months, when the Child's Classroom = Doodlebugs, the
visiting date needs to tell me the date on his 33 months. Can anyone
help me. I have such a hard time with IF statements. Your help is
greatly appreciated.
Thank you!

Maybe I should be using a bound text for the Visiting date that has
the formula in it.
 
G

Guest

You could add some code to the On_Current event of your form using the
DateAdd function. Example;

Private Sub Form_Current

If Me![Classroom] = "Bumble Bears" Then

Me![Visiting Date] = DateAdd ("m", 15, Me![DOB]) ' add 15 months to DOB

ElseIf Me![Classroom] = "Doodlebugs" Then

Me![Visiting Date] = DateAdd ("m", 33, Me![DOB])

End If

End Sub

Add however many Else If's you need for the possible values of the Classroom
control. If you have a lot of possibilities, it might be slightly easier to
code using a Select Case statement rather than an If...Then statement

You may also want to call this from the After_Update of your Classroom
control to make sure it stays up to date. Example;

Private Sub Classroom After_Update

Call Form_Current

End Sub

HTH
 
D

debbiep

You could add some code to the On_Current event of your form using the
DateAdd function. Example;

Private Sub Form_Current

If Me![Classroom] = "Bumble Bears" Then

Me![Visiting Date] = DateAdd ("m", 15, Me![DOB]) ' add 15 months to DOB

ElseIf Me![Classroom] = "Doodlebugs" Then

Me![Visiting Date] = DateAdd ("m", 33, Me![DOB])

End If

End Sub

Add however many Else If's you need for the possible values of the Classroom
control. If you have a lot of possibilities, it might be slightly easier to
code using a Select Case statement rather than an If...Then statement

You may also want to call this from the After_Update of your Classroom
control to make sure it stays up to date. Example;

Private Sub Classroom After_Update

Call Form_Current

End Sub

HTH



I am working in a form. I have a field called Visiting Date and a
field called DOB and a field called Classroom. I am trying to come up
with a formul in the Visiting date that will show if a Child's
Classroom = Bumble Bears, the visiting date needs to tell me the date
on his 15 months, when the Child's Classroom = Doodlebugs, the
visiting date needs to tell me the date on his 33 months. Can anyone
help me. I have such a hard time with IF statements. Your help is
greatly appreciated.
Thank you!- Hide quoted text -

- Show quoted text -

Actually what I am looking for is a formula that you can add in a
bound text box. I don't know where to find an On_Current. I do not
see it in the properties of the text box. Thanks n advance.
 

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