If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Adding months to a date of birth
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! |
#2
|
|||
|
|||
Adding months to a date of birth
On Sep 27, 9:22 pm, "
wrote: 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. |
#3
|
|||
|
|||
Adding months to a date of birth
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 " wrote: 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! |
#4
|
|||
|
|||
Adding months to a date of birth
On Sep 27, 10:15 pm, Beetle wrote:
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 " wrote: 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. |
Thread Tools | |
Display Modes | |
|
|