OA_Msg.bas 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. Option Compare Database
  2. Option Private Module
  3. Option Explicit
  4. Dim p_SilentMode As Boolean
  5. Public Sub activate_SilentMode()
  6. p_SilentMode = True
  7. End Sub
  8. Public Function SilentMode_activated() As Boolean
  9. SilentMode_activated = p_SilentMode
  10. End Function
  11. Public Function OA_MsgBox(ByVal msg As String, Optional ByVal buttons As Long, Optional title As String) As Integer
  12. If Not p_SilentMode Then
  13. OA_MsgBox = MsgBox(msg, buttons, title)
  14. Else
  15. logger "OA_MsgBox", "INFO", title & " - " & msg
  16. While buttons >= 16
  17. buttons = buttons - 16
  18. Wend
  19. Select Case buttons
  20. Case vbOKOnly
  21. OA_MsgBox = vbOK
  22. Case vbOKCancel
  23. OA_MsgBox = vbOK
  24. Case vbAbortRetryIgnore
  25. OA_MsgBox = vbIgnore
  26. Case vbYesNoCancel
  27. OA_MsgBox = vbYes
  28. Case vbYesNo
  29. OA_MsgBox = vbYes
  30. Case vbRetryCancel
  31. OA_MsgBox = vbCancel
  32. End Select
  33. logger "OA_MsgBox", "DEBUG", "Silent mode: OA_Msgbox returned " & OA_MsgBox
  34. End If
  35. End Function
  36. Public Function prompt_for_export_confirmation(ByVal newer_only As Boolean) As Boolean
  37. Dim msg As String
  38. msg = "**** OPENACCESS EXPORT ****" & vbNewLine & _
  39. "You're going to export the following:" & vbNewLine & vbNewLine & _
  40. msg_list_to_export(newer_only) & _
  41. ""
  42. prompt_for_export_confirmation = (OA_MsgBox(msg, vbOKCancel + vbExclamation, "Confirm") = vbOK)
  43. End Function
  44. Public Function prompt_for_import_confirmation() As Boolean
  45. Dim msg As String
  46. msg = "**** OPENACCESS IMPORT ****" & vbNewLine & _
  47. "You're going to update " & UCase(CurrentProject.name) & " with the sources files" & vbNewLine & vbNewLine & _
  48. "WARNING: Any non exported work would be lost!"
  49. prompt_for_import_confirmation = (OA_MsgBox(msg, vbOKCancel + vbExclamation, "Confirm") = vbOK)
  50. End Function