Automatic update using check boxes and a date field

  • Thread starter Thread starter MPayne
  • Start date Start date
M

MPayne

Guest
Help, I am trying to do an After Update with a check box and a date. The date is entered then a box is checked for 30, 60, or 90 days. The other date field needs to update with a calculated date. I believe I have the idea of it but I can't make it work.

1st -- I make a Option Group I include 30 Days, 60 Days and 90 Days as check boxes.

2nd -- I add two text boxes from the table list of Date 1 and Due Date.

3rd -- In preferences in the due date field I go to After Update and do an Event Procedure.

4th -- Once in Event procedure (Code) this is where I get lost.

Do I type:

If Check49.Value = 1 Then
DueDate.Value = Date1.Value + 30

ElseIf Check51.Value = 2 Then
DueDate.Value = Date1.Value + 60

ElseIf Check54.Value = 3 Then
Due Date.Value = Date1.Value + 90

EndElse

Please tell me if this is correct or what I am doing wrong.

Thanks in advance,
MPayne:confused: :confused:
 
1st - use radio buttons in your option group instead of checkboxes, that way only one will be selected at a time.

2nd - use the txtDate_AfterUpdate event and the OptionGroupFrameName_OnClick events to call ONE private function that makes the calculation regardless of which of the two events triggered it. You can also have it triggered with the form load event.

3rd - If you set your radio buttons "Option Values" to 30, 60, 90 respective of what they represent and the OptionsGroup default value to say 30 then when the form is first loaded 30 will always be selected and if you trigger the CalcDate function below with a form load event you always have somplace to start when the form is first opened

4th - The private function might look like the following:
Code:
Private Sub Form_Load()
    CalcDate
End Sub

Private Sub Frame0_Click()
    CalcDate
End Sub

Private Sub txtDate_AfterUpdate()
    CalcDate
End Sub

Private Function CalcDate() As Long
    Me.txtReviewDate = Format(DateAdd("d", Me![txtDate], Me![Frame0].[Value]), "dd/mmm/yyyy")
End Function
 
Last edited:
check out the attached:
 

Attachments

Users who are viewing this thread

Back
Top Bottom