AT_Access.bas 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 Sub wait(d As Single)
  8. Dim t0 As Single
  9. t0 = Timer
  10. While Timer - t0 < d
  11. DoEvents
  12. Wend
  13. End Sub
  14. Public Sub test()
  15. Dim pdial As New ProgressDialog
  16. pdial.show "My progress bar", "Operation running...", 100, False
  17. For i = 0 To 100
  18. wait (0.02)
  19. pdial.update i, "Operation running..."
  20. Next i
  21. End Sub
  22. Public Function table_exists(tname As String) As Boolean
  23. Dim td As Object
  24. table_exists = False
  25. For Each td In CurrentDb.TableDefs
  26. If td.name = tname Then
  27. table_exists = True
  28. Exit Function
  29. End If
  30. Next td
  31. End Function
  32. Public Function query_exists(qname As String) As Boolean
  33. Dim rd As Object
  34. query_exists = False
  35. For Each rd In CurrentDb.QueryDefs
  36. If rd.name = nom Then
  37. query_exists = True
  38. Exit Function
  39. End If
  40. Next rd
  41. End Function
  42. Public Function form_exists(fname As String) As Boolean
  43. Dim frm As Object
  44. form_exists = False
  45. For Each frm In CurrentProject.AllForms
  46. If frm.name = fname Then
  47. form_exists = True
  48. GoTo fin
  49. End If
  50. Next frm
  51. fin:
  52. End Function
  53. Public Function report_exists(rname As String) As Boolean
  54. Dim rpt As Object
  55. report_exists = False
  56. For Each rpt In CurrentProject.AllReports
  57. If et.name = rname Then
  58. etatExiste = True
  59. GoTo fin
  60. End If
  61. Next rpt
  62. fin:
  63. End Function
  64. Public Function form_is_opened(fname As String) As Boolean
  65. form_is_opened = False
  66. If Not form_exists(fname) Then Exit Function
  67. form_is_opened = CurrentProject.AllForms(fname).IsLoaded
  68. End Function
  69. Public Function report_is_opened(rname As String) As Boolean
  70. report_is_opened = False
  71. If Not report_exists(rname) Then Exit Function
  72. report_is_opened = CurrentProject.AllReports(rname).IsLoaded
  73. End Function
  74. Public Function is_opened(objtype As Integer, objname As String) As Boolean
  75. is_opened = False
  76. IsTableOpened = SysCmd(acSysCmdGetObjectState, objtype, objname)
  77. End Function