A
Andy
Hi;
The code below "Automates the Report's Title", (ala Martin Green).
It works correctly, when the user enters the date ranges and clicks the OK
button.
If the user clicks the Cancel button the error trap msg is displayed.
What is needed is something along the lines of "vbOkCancel" that works with
a MsgBox.
When a MsgBox is used the code either doesn't work at all or the MsgBox
appears before the "Between And" dialog box appears and the Cancel on the
dialog box still displays the Error Trap Msg.
Have searched Microsoft MSDN and KB and, and, and a few "Gazillion" more and
haven't found the solution. Would someone be so kind to point me in the
correct direction?
Thank You for taking the time to read this Post.
Andy
Private Sub cmdContractDateRange_Click()
On Error GoTo Err_cmdContractDateRange_Click
Dim strCriteria As String
strCriteria = "[ContractDate] Between [Enter Beginning Contract Date:]
And [Enter Ending Contract Date:]"
' Change the Report Label
DoCmd.Echo False
DoCmd.OpenReport "rptContracts", acViewDesign
With Reports("rptContracts")
.Controls("lblrptCriteria").Caption = "By Date Range"
End With
DoCmd.Close , , acSaveYes
DoCmd.Echo True
' Open the Report
DoCmd.OpenReport "rptContracts", acPreview, , strCriteria
Exit_cmdContractDateRange_Click:
Exit Sub
Err_cmdContractDateRange_Click:
MsgBox "This command ''cmdContractDateRange'' isn't working correctly. "
& vbCrLf & "Please inform Your manager."
Resume Exit_cmdContractDateRange_Click
End Sub
The code below "Automates the Report's Title", (ala Martin Green).
It works correctly, when the user enters the date ranges and clicks the OK
button.
If the user clicks the Cancel button the error trap msg is displayed.
What is needed is something along the lines of "vbOkCancel" that works with
a MsgBox.
When a MsgBox is used the code either doesn't work at all or the MsgBox
appears before the "Between And" dialog box appears and the Cancel on the
dialog box still displays the Error Trap Msg.
Have searched Microsoft MSDN and KB and, and, and a few "Gazillion" more and
haven't found the solution. Would someone be so kind to point me in the
correct direction?
Thank You for taking the time to read this Post.
Andy
Private Sub cmdContractDateRange_Click()
On Error GoTo Err_cmdContractDateRange_Click
Dim strCriteria As String
strCriteria = "[ContractDate] Between [Enter Beginning Contract Date:]
And [Enter Ending Contract Date:]"
' Change the Report Label
DoCmd.Echo False
DoCmd.OpenReport "rptContracts", acViewDesign
With Reports("rptContracts")
.Controls("lblrptCriteria").Caption = "By Date Range"
End With
DoCmd.Close , , acSaveYes
DoCmd.Echo True
' Open the Report
DoCmd.OpenReport "rptContracts", acPreview, , strCriteria
Exit_cmdContractDateRange_Click:
Exit Sub
Err_cmdContractDateRange_Click:
MsgBox "This command ''cmdContractDateRange'' isn't working correctly. "
& vbCrLf & "Please inform Your manager."
Resume Exit_cmdContractDateRange_Click
End Sub