error handling code

action

Registered User.
Local time
Tomorrow, 05:00
Joined
May 29, 2003
Messages
89
Hi, I have need to put a error message and action into some code that runs a report for a day's A/R activity. When I run the code where no activity has taken place (ie in the future or a closed day) I get the error 2427

my code is:

Private Sub CmdDailytransactions_Click()
On Error GoTo Err_CmdDailytransactions_Click

Dim stDocName As String

stDocName = "Yesterdays Account Activity"
DoCmd.OpenReport stDocName, acPreview

Exit_CmdDailytransactions_Click:
Exit Sub

Err_CmdDailytransactions_Click:
MsgBox Err.Description
Resume Exit_CmdDailytransactions_Click

End Sub


The error happens because the reporting format has no data to run this:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.[Payment] = "0" Then
Me.[Payment].Visible = False
Else
Me.[Payment].Visible = True
End If
If Me.[Charge] = "0" Then
Me.[Charge].Visible = False
Else
Me.[Charge].Visible = True

End If

End Sub



I am not really sure where to put the error handling and if so what to put. Comments? Thanks
 
Use the NoData event of the report
Cancel = True
MsgBox, "There is no data for the period selected"
 

Users who are viewing this thread

Back
Top Bottom