AT_Access.bas 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. End Function
  52. Public Function report_exists(rname As String) As Boolean
  53. Dim rpt As Object
  54. report_exists = False
  55. For Each rpt In CurrentProject.AllReports
  56. If et.name = rname Then
  57. etatExiste = True
  58. GoTo fin
  59. End If
  60. Next rpt
  61. End Function
  62. Public Function form_is_opened(fname As String) As Boolean
  63. form_is_opened = False
  64. If Not form_exists(fname) Then Exit Function
  65. form_is_opened = CurrentProject.AllForms(fname).IsLoaded
  66. End Function
  67. Public Function report_is_opened(rname As String) As Boolean
  68. report_is_opened = False
  69. If Not report_exists(rname) Then Exit Function
  70. report_is_opened = CurrentProject.AllReports(rname).IsLoaded
  71. End Function