How to determine which button was clicked

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.
 
K

Ken Snell \(MVP\)

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top