Posted By

corydeppen on 03/25/07


Tagged

access vba 2003 vb


Versions (?)

ObjectExists


 / Published in: Visual Basic
 

  1. Function ObjectExists(ObjectType As String, ObjectName As String) As Boolean
  2.  
  3. Dim obj As AccessObject
  4.  
  5. Select Case ObjectType
  6. Case "Table"
  7. For Each obj In CurrentData.AllTables
  8. If obj.Name = ObjectName Then
  9. ObjectExists = True
  10. Exit For
  11. End If
  12. Next obj
  13. Case "Query"
  14. For Each obj In CurrentData.AllQueries
  15. If obj.Name = ObjectName Then
  16. ObjectExists = True
  17. Exit For
  18. End If
  19. Next obj
  20. Case "Form"
  21. For Each obj In CurrentProject.AllForms
  22. If obj.Name = ObjectName Then
  23. ObjectExists = True
  24. Exit For
  25. End If
  26. Next obj
  27. Case "Report"
  28. For Each obj In CurrentProject.AllReports
  29. If obj.Name = ObjectName Then
  30. ObjectExists = True
  31. Exit For
  32. End If
  33. Next obj
  34. End Select
  35.  
  36. End Function

Report this snippet  

You need to login to post a comment.