Full Version: Beforeupdate Event
UtterAccess Forums > Microsoft® Access > Access Forms
Eightball3
Hello all!

I have a combo box on a sub form. The limit to list property is set to yes. The box initially contains no value. When the user selects an item from the list and moves from that control, I am trying to use the beforeupdate event to put up a message box to confirm the change. If yes, the change stands and I move the focus to a different control. If no, I remove the value selected (place it back to null) and move the focus to a different control. The problem I'm having is I get an error message that states you have to save the field before you can setfocus. Can someone tell me what I'm doing wrong. Am I using the right events. As always, thanks!
bluedanube
You may try to use the .Undo method of that control.
Eightball3
That doesn't seem to work. The combo box is an unbound control, would that make a difference?
bluedanube
I see.. no undo for unbound controls.

different approach - it is the .text property that can't be saved to the control when it is NULL but NULL not included in the list of supported values or recordset.

for such a purpose (empty field has to be a valid option) I usually create a union query from the basic combo or listbox query, where I add a row that returns the empty value.

example:
SELECT COLOR FROM MYCOLORS UNION SELECT '' FROM DUAL ORDER BY COLOR

(were DUAL is a dummy table you need to create with one row and one or two columns. using this table is a habit in oracle programming.)
you may want to test whether SELECT '' or SELECT NULL works better with the particular control, to create an empty value.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.