VBA Coding Approaches
Home ] Access - Start Here ] Excel In Depth ] MS Office ] Visio Info ] Creating Web Pages ] Technical References ] Viruses ] Points of View ] Gadgets ] Just Links ] Monash ]

   Search this site or the web       powered by FreeFind
 
  Site search Web search

Participate in Ananda's Discussions
Post a message

Monitor page
for changes
    
   it's private  

by ChangeDetection

Up

Approaches to reduce Code Generation and Maintenance

  1. Rely on native application behaviour and functionality in contrast to over-riding native behaviour.
    1. Know and use Form Behaviour to advantage.
    2. Do not obscure Report Print Preview menu.
    3. In Report and Form surfaces where it is possible to shrink Controls or otherwise hide Control visibility, make it explicit that the Object is hidden.
  2. Discourage extra programming to provide "gloss" in user interface rather than data integrity. Extra programming always causes:
    1. more work.
    2. more dependency on Operating System Version / API.
    3. more bugs if there are any.
    4. assumptions on object names and behaviours which may or may not be impacted by application revision or newer versions of the host software.
  1. Implement database engine rules upfront and in the following order:
    1. Appropriate data type
    2. Input Mask
    3. Validation Rule
    4. Referential Integrity
    5. Combo Box (Not in List) - facility should be built in to allow the user to easily add to the reference list.
    6. For most projects, unless particular forms are performance hit, use data bound forms and bound controls.

Coding Approaches

  1. Mandatory use of Option Explicit.
  2. Dim declarations followed by variable initialisations should be at the head of the Modules and Procedures.
  3. Use of dot syntax vs bang. (Bang disables Intellisense)
  4. Although it increased parsing time, it reduces typing and spelling errors - precede current form objects, methods and properties with "Me".
  5. Indent code appropriately.
  6. Use Error Handling unless incompatible.
  7. Avoid Docmd object path wherever possible.
  8. Use DAO in preference to ADO for Access Jet databases.
  9. Code should be in short routines - encourage use of subroutine calls with provisos.
    1. Do not over nest subroutine calls.
    2. Where clarity is improved e.g. in executing a long sequence of queries, calling code should be kept in one long routine.
  10. Source code line length should be within printable limits. Use the underscore ("_") to extend to the next line.