G
Guest
I would like create reports for the following, would appreciate if someone
could let me know what is wrong with my code, because the report just ignores
the selection values. Thanks a lot!
1. Select date between [date] and [date].
------------------------------------------
Private Sub View_Report_Click()
On Error GoTo Err_View_Report_Click
Dim stDocName As String
Dim strWhere As String
Dim strJoin As String
If IsNull([BeginDate]) And IsNull([EndDate]) Then
MsgBox "Please enter Begin Date and End Date."
DoCmd.GoToControl "BeginDate"
ElseIf IsNull([BeginDate]) Then
MsgBox "Please enter the Begin Date."
DoCmd.GoToControl "BeginDate"
ElseIf IsNull([EndDate]) Then
MsgBox "Please enter the End Date."
DoCmd.GoToControl "EndDate"
ElseIf [BeginDate] > [EndDate] Then
MsgBox "The End Date must be greater than Begin Date."
DoCmd.GoToControl "BeginDate"
Else
strWhere = "[TransactionDate] BETWEEN " & Me.[BeginDate] & " And " &
Me.[EndDate]
stDocName = "TR_Search_Bank sort by JCompany"
DoCmd.OpenReport stDocName, acPreview, , strWhere
DoCmd.Close acForm, "Dialog_Search by MY"
End If
Exit_View_Report_Click:
Exit Sub
Err_View_Report_Click:
DoCmd.Close acForm, "Dialog_Search by MY"
Resume Exit_View_Report_Click
End Sub
could let me know what is wrong with my code, because the report just ignores
the selection values. Thanks a lot!
1. Select date between [date] and [date].
------------------------------------------
Private Sub View_Report_Click()
On Error GoTo Err_View_Report_Click
Dim stDocName As String
Dim strWhere As String
Dim strJoin As String
If IsNull([BeginDate]) And IsNull([EndDate]) Then
MsgBox "Please enter Begin Date and End Date."
DoCmd.GoToControl "BeginDate"
ElseIf IsNull([BeginDate]) Then
MsgBox "Please enter the Begin Date."
DoCmd.GoToControl "BeginDate"
ElseIf IsNull([EndDate]) Then
MsgBox "Please enter the End Date."
DoCmd.GoToControl "EndDate"
ElseIf [BeginDate] > [EndDate] Then
MsgBox "The End Date must be greater than Begin Date."
DoCmd.GoToControl "BeginDate"
Else
strWhere = "[TransactionDate] BETWEEN " & Me.[BeginDate] & " And " &
Me.[EndDate]
stDocName = "TR_Search_Bank sort by JCompany"
DoCmd.OpenReport stDocName, acPreview, , strWhere
DoCmd.Close acForm, "Dialog_Search by MY"
End If
Exit_View_Report_Click:
Exit Sub
Err_View_Report_Click:
DoCmd.Close acForm, "Dialog_Search by MY"
Resume Exit_View_Report_Click
End Sub