Wizards That Modify Access Basic Code

Although it is not supported by Microsoft, you can build Wizards that read and write Access Basic code. These can be used to paste in commonly used code fragments such as error handlers, comment blocks, etc. They can also be used to edit existing code. Once you've built and debugged your Code Wizards, install them as library databases in the [Libraries] section of the .INI file just as you would any other Wizard. You hook up the entry point by registering your Code Wizard as a Property Wizard with the property name Module in the .INI file like this:


[Property Wizards]
MYAccessBasicCodeBuilder=Module, Function Paster, FP_Entry, rw

Restart Access and open a Module Window. Select lines of code you want your Wizard to process and chose the Build... button from the right-click menu. If more than one Code Wizard is available the user will be prompted to chose between them. The selected text will be passed into the Wizard. After your Wizard has processed the text, the return value of your Wizard will be pasted back over the user's original selection.

Code Wizards are NOT SUPPORTED BY MICROSOFT. There are two reasons for this: First, there is a known bug whereby selecting Undo immediately after running a Code Wizard sometimes causes the Undo stack to behave incorrectly. Second, future releases of Microsoft Access will use native Visual Basic for Applications (VBA). VBA will be fully backward-compatible with Access Basic code, and it's unclear at this time if VBA will support the same self-modifying capability. Therefore, if you choose to write Wizards that modify code, do so at your own risk. Product Support Services will not support them and they may not work in future versions.