Link to home
Start Free TrialLog in
Avatar of vstopp
vstoppFlag for United States of America

asked on

Query based on combo box: Error 2118 - You must save field before requery action

I have a subform that is based on a query which looks to the value in the combo box.  

Combo Box OnChange event contains subform.requery method

The combo box on the subform from a column in the underlying record source.  When I select a value in the combo box, the requery method works perfect and just displays those records which meet the criteria in the combo box.

When I clear the combo box (by deleting the data), and the requery method tries to execute (on change event), I get the following error:

'Run-time error 2118'
You must save the current field before you run the Requery Action.

If I halt out of code and the press "F9", the record source displays all the records.

Is there any workaround to this bug/problem?

Thank you for your help.

P.S.  Interesting Note:  I put a button on the subform to set the combo box = null and then execute the requery, and everything works fine.  The problem lies wherein I delete the data from the combo box using the Delete Key, the on change event is triggered, and the subform is requeried....  That is when I get the above error.
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vstopp

ASKER

Works very well.  For some reason, I tried the after update event first, but it did not behave as expected???? But now it does :)  The only problem is the user will have to remember to press "enter" after they delete the value because nothing happens when just the "delete" key is pressed and the value erased in this manner.

Maybe I'm a little bleary eyed from too much programming lol!

Thank you so much for your time.  
Sincerely,
Val
Avatar of vstopp

ASKER

Once again, thank you for your time in responding.  I appreciate it very much.  I am a solo contract programmer working with MSAccess for over 20 years, and sometimes I just get stumped and always turn to Experts Exchange for answers to my questions...  Most of the time they have the most valuable answers.