AT_Access.bas 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. Option Compare Database
  2. ' ** Access Toolbox Module **
  3. ' on 2017-02-28,
  4. ' @author: Olivier Massot
  5. ' V 1.0
  6. ' Operations on access objects: tables, queries, forms, reports, macros, modules
  7. Public Function table_exists(tname As String) As Boolean
  8. Dim td As Object
  9. table_exists = False
  10. For Each td In CurrentDb.TableDefs
  11. If td.name = tname Then
  12. table_exists = True
  13. Exit Function
  14. End If
  15. Next td
  16. End Function
  17. Public Function query_exists(qname As String) As Boolean
  18. Dim rd As Object
  19. query_exists = False
  20. For Each rd In CurrentDb.QueryDefs
  21. If rd.name = nom Then
  22. query_exists = True
  23. Exit Function
  24. End If
  25. Next rd
  26. End Function
  27. Public Function form_exists(fname As String) As Boolean
  28. Dim frm As Object
  29. form_exists = False
  30. For Each frm In CurrentProject.AllForms
  31. If frm.name = fname Then
  32. form_exists = True
  33. GoTo fin
  34. End If
  35. Next frm
  36. End Function
  37. Public Function report_exists(rname As String) As Boolean
  38. Dim rpt As Object
  39. report_exists = False
  40. For Each rpt In CurrentProject.AllReports
  41. If et.name = rname Then
  42. etatExiste = True
  43. GoTo fin
  44. End If
  45. Next rpt
  46. End Function
  47. Public Function form_is_opened(fname As String) As Boolean
  48. form_is_opened = False
  49. If Not form_exists(fname) Then Exit Function
  50. form_is_opened = CurrentProject.AllForms(fname).IsLoaded
  51. End Function
  52. Public Function report_is_opened(rname As String) As Boolean
  53. report_is_opened = False
  54. If Not report_exists(rname) Then Exit Function
  55. report_is_opened = CurrentProject.AllReports(rname).IsLoaded
  56. End Function