Hold_it

MSAccess Context Primer.md

Dec 10th, 2025
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | Software | 0 0
  1. # Access VBA Project Context Primer
  2.  
  3. ## 1. Data Access Model
  4. The project uses Microsoft Access native DAO as the primary data access layer.
  5. Rules:
  6. - DAO.Recordset and DAO.Database are preferred.
  7. - ADO is used only where explicitly referenced.
  8. - QueryDefs represent named queries; SQL strings represent dynamic queries.
  9. - Bound forms use RecordSource for data binding.
  10. - Unbound forms use manual DAO to populate controls.
  11.  
  12. ## 2. Form Event Model
  13. Access forms have a strict event order:
  14. - Load → Open → Current → Activate
  15. - BeforeUpdate → AfterUpdate are used for validation and saving.
  16. - Dirty state indicates unsaved changes.
  17. - Form_Current triggers when navigating between records.
  18. - Record-level validation occurs in BeforeUpdate.
  19.  
  20. ## 3. Bound Form Behavior
  21. Bound forms automatically:
  22. - Manage record navigation.
  23. - Handle locking and concurrency.
  24. - Commit changes when focus leaves control or DoCmd.RunCommand acCmdSaveRecord.
  25. - Reject updates in BeforeUpdate via Cancel = True.
  26.  
  27. ## 4. Module-Level Structure
  28. Public functions serve as application-level APIs.
  29. Private functions are internal helpers.
  30. Utility modules contain reusable logic such as:
  31. - Date/time helpers
  32. - Error handling
  33. - Validation routines
  34. - Recordset helpers
  35.  
  36. ## 5. Queries
  37. QueryDefs:
  38. - Represent stored queries in Access.
  39. - Often used as templates with parameters or SQL replaced dynamically.
  40.  
  41. SQL strings:
  42. - Used for dynamic filtering, searching, or temporary operations.
  43.  
  44. Pass-through queries:
  45. - Forward SQL directly to the backend DB (if present).
  46.  
  47. ## 6. Error Handling Conventions
  48. The project uses structured error handlers of this form:
  49. On Error GoTo Err_Handler
  50. ...
  51. Exit Function/Exit Sub
  52. Err_Handler:
  53. HandleError Err.Number, Err.Description
  54.  
  55. ## 7. Naming Conventions
  56. (Optional: Add your own naming rules)
  57. - frmSomething = Forms
  58. - rptSomething = Reports
  59. - modSomething = Standard modules
  60. - clsSomething = Classes
  61. - qdf = QueryDef
  62. - rs = Recordset
  63.  
  64. ## 8. General Environment Notes
  65. - This is Access Desktop VBA, not VB6 and not .NET.
  66. - Syntax must follow Access VBA rules.
  67. - The default database engine is Jet/ACE.
  68. - No asynchronous operations; all DAO is synchronous.
Advertisement
Add Comment
Please, Sign In to add comment