Originally Posted by
June7
Code does quite follow my syntax. Several options for referencing forms.
If you look at objects listed in VBE, you will see prefixes like Form_, Report_.
Form_frmDateCal.NewDate
or
Forms!frmDateCal.NewDate
or
Me.NewDate
Me can be used as alias for form the code is behind.
Okay. Here is my take on it again but not sure if I have it correctly placed code wise. Again when the user selects 'Form Two' in the "FormType" within the Form_frmDateCal; the Form_frmDatePicker opens as a Dialog for the user to select a start and end date. Then the number of days between the two dates will be added to the lastDate within the Form_frmDateCal plus additional 365 days.
Code:
Private Sub ReportType_AfterUpdate()
Select Case ReportType
Case 1 'Form One selected
Me.NewDate = DateAdd("d", 364, Me.LastDate)
Case 2 'Form Two selected
DoCmd.OpenForm "frmDatePicker", , , , , acDialog, "Logout"
Dim DValue As Integer
DValue = DateDiff("d", frmDatePicker.StartDate, frmDatePicker)
If CurrentProject.AllForms("frmDatePicker").IsLoaded Then
frmDateCal.NewDate = DValue + frmDateCal.LastDate + 365
DoCmd.Close acForm, "frmDatePicker", acSaveNo
End If
Case 3 'From Three selected
Me.NewDate = DateAdd("d", 406, Me.LastDate)
End Select
End Sub