Combobox Enter Event doesn´t fire

Ana2010

New member
Local time
Today, 16:08
Joined
Dec 4, 2010
Messages
8
Windows 7 Starter
Access 2007

I want to check if the value of a combobox has changed when a user selects an item, and if it did, display a message to confirm changes. The OldValue property is not usefull because I need the message to display each time the value of the combo is changed and not only when the value selected is different from the original value of the record. So I write code in the Enter Event to get the actual value of the combo and in the UfterUpdate Event to display the message and undo the change if the change is not confirmed.
The problem is that clicking on the text box portion of the combobox the Enter Event does fire but clicking on the arrow part it doesn't!
 
The actual VALUE of the combo box doesn't reflect a change until the AFTER UPDATE event. You can use the combo's BEFORE UPDATE event to test for old and new values and then use Cancel = True in that Before Update event if the validation fails and then use a Me.ComboBoxNameHere.Undo to undo the input.
 
Bob's advice is right on the money, but FYI, to detect both moving into a combobox and when the arrow is clicked, use the GotFocus event.
 
Thank you for your answers, both are usefull for me!
But I still have a more wide situation I can´t solve. This is the general scenario:
I have a mainform with a subform. I wish the behavior of the mainform and subform be like this:
1. Every time the user changes the value in a control, send a message to confirm changes (the solution you gave me works here)
2. Have an Undo button to undo edits made to the mainform record as well as multiple edits to subforms records. I´m working on a solution by making a copy of the mainform and subform records into temporary tables during the Current Event and then, when the Undo button is clicked, copy all the field values saved in the temp tables back over the mainform and the subform. I don´t have this technique finished yet, I´m having some troubles I´m working on (may be I will be posting something about this in the near future...)

One more question: I have another CommandButton in the mainform that when clicked deletes all records on the subform that match a criteria and adds 3 new records with data. One of these fields is an Integer that I initialized to 0 on every 3 record added to the subform but then the user must edit and enter a number different to 0. I want to check that this field is not left 0 in any of the records in the subform. I tried some ways to do this but can't find one that works yet. Any suggestions??
 

Users who are viewing this thread

Back
Top Bottom