R
Robert T
Hello:
I created a simple dialog form that accepts a Start and End Date for a
report. So far it seems to be working very well, however, the dialog form
doesn't close, it remains open on the screen. Where and how do I close the
dialog form? Is it done from the Report?
Form Name: dfrmWhatDates
Form Fields: vStartDate and vEndDate
Here is the code behind the cmdRpt box.
Private Sub cmdRpt_Click()
Dim strReport As String 'Name of report to open.
Dim strField As String 'Name of the date field.
Dim strWhere As String 'Where condition to open the Report.
Const conDateFormat = "\#mm\/dd\/yyyy\#"
strReport = "rptTSR_Classes"
strField = "Class_Date"
If IsNull(Me.vStartDate) Then
MsgBox ("Start Date is Missing")
Me.vStartDate.SetFocus
'Cancel = True
GoTo End_Sub
End If
If IsNull(Me.vEndDate) Then
MsgBox ("End Date is Missing")
Me.vEndDate.SetFocus
'Cancel = True
GoTo End_Sub
End If
If Me.vEndDate < Me.vStartDate Then
MsgBox ("The End Date cannot come before the Start Date")
Me.vEndDate.SetFocus
GoTo End_Sub
End If
strWhere = strField & " Between " & Format(Me.vStartDate, conDateFormat) _
& " And " & Format(Me.vEndDate, conDateFormat)
DoCmd.OpenReport strReport, acViewPreview, , strWhere
'DoCmd.Close
End_Sub:
End Sub
I created a simple dialog form that accepts a Start and End Date for a
report. So far it seems to be working very well, however, the dialog form
doesn't close, it remains open on the screen. Where and how do I close the
dialog form? Is it done from the Report?
Form Name: dfrmWhatDates
Form Fields: vStartDate and vEndDate
Here is the code behind the cmdRpt box.
Private Sub cmdRpt_Click()
Dim strReport As String 'Name of report to open.
Dim strField As String 'Name of the date field.
Dim strWhere As String 'Where condition to open the Report.
Const conDateFormat = "\#mm\/dd\/yyyy\#"
strReport = "rptTSR_Classes"
strField = "Class_Date"
If IsNull(Me.vStartDate) Then
MsgBox ("Start Date is Missing")
Me.vStartDate.SetFocus
'Cancel = True
GoTo End_Sub
End If
If IsNull(Me.vEndDate) Then
MsgBox ("End Date is Missing")
Me.vEndDate.SetFocus
'Cancel = True
GoTo End_Sub
End If
If Me.vEndDate < Me.vStartDate Then
MsgBox ("The End Date cannot come before the Start Date")
Me.vEndDate.SetFocus
GoTo End_Sub
End If
strWhere = strField & " Between " & Format(Me.vStartDate, conDateFormat) _
& " And " & Format(Me.vEndDate, conDateFormat)
DoCmd.OpenReport strReport, acViewPreview, , strWhere
'DoCmd.Close
End_Sub:
End Sub