Can't figure out undo

G

Guest

Boy do I need help. I have a combo box on a form, cboSAR_ID. Based on the
value the user enters in cboSAR_ID I populate many other text boxes and list
boxes on the form. If the user enters a different value in cboSAR_ID--no
problem--I can handle that. If the user hits the "Esc" button and undos the
cboSAR_ID entry, I want to give a warning and then if the user wants to undo,
then I need to clear all the other fields. If the user chooses not to undo,
I want to put back the value in cboSAR_ID.

This sounds simple enough, but I have tried entering code in the Undo,
BeforeUpdate and AfterUpdate events of cboSAR_ID (those events are not
triggered with "Esc").

The Form_Undo event is triggered, but that event is triggered when any
control is cleared. How can I check to see if it was the cboSAR_ID control
that the user chose to undo?

Thank you for any help you can give me,
Judy
 
M

Marshall Barton

Judy said:
Boy do I need help. I have a combo box on a form, cboSAR_ID. Based on the
value the user enters in cboSAR_ID I populate many other text boxes and list
boxes on the form. If the user enters a different value in cboSAR_ID--no
problem--I can handle that. If the user hits the "Esc" button and undos the
cboSAR_ID entry, I want to give a warning and then if the user wants to undo,
then I need to clear all the other fields. If the user chooses not to undo,
I want to put back the value in cboSAR_ID.

This sounds simple enough, but I have tried entering code in the Undo,
BeforeUpdate and AfterUpdate events of cboSAR_ID (those events are not
triggered with "Esc").

The Form_Undo event is triggered, but that event is triggered when any
control is cleared. How can I check to see if it was the cboSAR_ID control
that the user chose to undo?


If the combo box still has the focus, you can reference it
using Me.ActiveControl. If the combo box does not have the
focus, how do you know the Esc applies to the combo box??
 
G

Guest

Thank you for your response.

You asked "how do you know the Esc applies to the combo box?". I know, as
the user, that I chose "Esc" after entering a SAR ID in cboSAR_ID. I am
trying to capture that event and write code that will clear out other fields.
So far, the only event that I have found that is triggered when the user
chooses "Esc" after making an entry in the combo box is the form undo event.
But, as you know, any Esc will trigger the form undo event. I was hoping to
put an if condition in the form undo event checking to see if it was indeed
the cboSAR_ID that the user cleared out (and then I will know it is
appropriate to clear out the related fields).

I don't quite understand how I would use Me.ActiveControl. Can I test to
see if Me.ActiveControl = Me.cboSAR_ID?

I am also open to other suggestions of how to handle this scenario.

Thank you,
Judy
 
M

Marshall Barton

Yes you can test it:

If Me.ActiveControl.Name = "cboSAR_ID" Then

I guess that test is what you want to use to verify that the
combo box still has the focus (i.e. user has not moved to
another control).
 

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