Prev | Current Page 919 | Next

Michael R. Groh, Joseph C. Stockman, Gavin Powell, and Cary N. Prague

"Access 2007 Bible"

The Products command button, for
example, runs the event procedure to open frmProducts. Figure 12-4 shows the Properties window
for the Product command button, called cmdProducts. Figure 12-5 shows the VBA code for
the Click event of the cmdProducts command button.
FIGURE 12-4
Specifying an event procedure for a control event
432
Programming Microsoft Access Part II
FIGURE 12-5
Using an event procedure to open a form
Running an event procedure when closing a form
At times, you??™ll want to perform some action when you close or leave a form. For example, you
may want Access to keep an automatic log of the names of everyone using the form, or you may
want to close the form??™s print dialog box automatically every time a user closes the main form.
To automatically close frmDialogProductPrint every time frmProducts is closed, create an
event procedure for frmProducts Close event. Figure 12-6 shows the VBA code for
frmProducts Close event.
FIGURE 12-6
Running an event procedure when a form closes
The Form_Close event illustrated in Figure 12-6 first checks to see if the form
frmDialogProductPrint is open.


Pages:
907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931
gry dla dziewczyn Laptopy i netbooki Horrory, thrillery opony Kalendarze indywidualne