From DevHut[1]
' Procedure : DoesRptExist
' Author    : CARDA Consultants Inc.
' Website   :
' Purpose   : Determine if the specified report exists or not in the current database
' Copyright : The following may be altered and reused as you wish so long as the
'             copyright notice is left unchanged (including Author, Website and
'             Copyright).  It may not be sold/resold or reposted on other sites (links
'             back to this site are allowed).
' Input Variables:
' ~~~~~~~~~~~~~~~~
' sReportName : Name of the report to check the existance of
' Usage Example:
' ~~~~~~~~~~~~~~~~
' DoesRptExist("Report1")
' Revision History:
' Rev       Date(yyyy/mm/dd)        Description
' **************************************************************************************
' 1         2010-Feb-02             Initial Release
Function DoesRptExist(sReportName As String) As Boolean
   Dim rpt  As Object
On Error GoTo Error_Handler
   'Initialize our variable
   DoesRptExist = False
   Set rpt = CurrentProject.AllReports(sReportName)
   DoesRptExist = True  'If we made it to here without triggering an error
                        'the report exists

   On Error Resume Next
   Set rpt = Nothing
   Exit Function
   If Err.Number = 2467 Then
      'If we are here it is because the report could not be found
      MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf & "Error Number: " & _
      Err.Number & vbCrLf & "Error Source: DoesRptExist" & vbCrLf & "Error Description: " & _
      Err.Description, vbCritical, "An Error has Occured!"
   End If
   Resume Error_Handler_Exit
End Function



Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.