Pages

Tuesday, January 3, 2012

Check if Report Exists in the database

If you want to find out whether a particular report exists in the database or not.

Here is the code-

Sub check_if_report_exists()
Dim rptname As String
Dim rpt As Object
Dim found As Boolean
rptname = "rep_name_a"
found = False
For Each rpt In Application.CurrentProject.AllReports
If rpt.Name = rptname Then
found = True
Exit For
End If
Next
If found = True Then
MsgBox "Report found", vbInformation
Else
MsgBox "Report Not Found", vbInformation
End If
End Sub

No comments:

Post a Comment