Open Form Or Report Using Button Caption
moving away from macros and into the world of event procedures! Congratulations!
You're well on your way to unleashing more of the power of Microsoft® Access®.
But, wait a minute. You've been using simple macros from command buttons
to open forms, and reports. What do you do now?
All you have to do is put a call to this function in your command button OnClick property - "=OpenFrmOrRptUsingCaption()" (without the quotes). Then you can:
1. Put the
name of the form or report to open in the command button tag property,
Using option number 2 above can dramatically simplify your application design, especially if you use standard naming conventions, and descriptive form and report names. For example: If your command button caption is "&Orders", then, when the button is clicked, the function will attempt to open a form named "frmOrders" (The ampersand "&" in the button caption is ignored). If that form does not exist in your database, then the function will assume it is a report, and it will attempt to open a report named "rptOrders".
Using this function eliminates the need to have one macro to open each form or report. One easy-to-use function does it all, and you only have to maintain the button caption property!
To use this function, copy the code below into a new module, then put the function call ("=OpenFrmOrRptUsingCaption()") in your command button OnClick property:
To see the function, click here.
Copyright © 1998-2002 Peter's Software