How to determine which button was clicked

  • Thread starter Thread starter dhstein
  • Start date Start date
D

dhstein

I am doing some function in the Form_BeforeUpdate event. I can get there
from 2 different buttons. Both buttons are executing embedded macro
functions (one is SAVE and 1 is EXIT). How can I check which button was
clicked? Thanks for any help on this.
 
Assuming that the button still has the focus when the Form_BeforeUpdate
event runs, read the name of the button:

Dim strButtonName As String
strButtonName = Me.ActiveControl.Name


Otherwise, establish a global local variable in the form's module, and set
the value of that variable with the name of the button in the button's click
event. Then read that variable in the Form_BeforeUpdate event code.
 
Back
Top