Requery a ComboBox error!

  • Thread starter Thread starter Alastair MacFarlane
  • Start date Start date
A

Alastair MacFarlane

Dear All

I have 2 forms: Form A and Form B. On form A I have a
ComboBox that loads values from a table. The ComboBox has
its "LimitToList" set to true because it is bound to
column 2 of the Rowsource property. When I want to add a
new record to the table and appear in the ComboBox, I
double-click the ComboBox to open up form B to add a new
value, save the new record, and requery the combobox in
Form A, and close form B.

Most of the time it works fine, with one exception, if a
user enters a value not on the list of the ComboBox,
double-clicks it to add a new record on Form B and runs
the Requery action on the ComboBox, I get the error:

Error 2118: You must sve the current field before you run
the requery action.

I have tried, more in desperation than understanding a
possible solution, to look at Sendkeys "{ESC} {ESC}" or
setting the ComboBox to "". Neither will work. I cannot
save Form A because there are other foreign key values
that must be added to save the record.

Can anyone suggest a possible solution?

Thanks again.

Alastair MacFarlane
 
Alistair

Look up the help system for the NotInList event. It
fires on a combo box when two conditions are true:

1) LimitToList = true
2) The entered data in the combo's text portion is not in
the drop down list

The event handler subroutine is handed a copy of the
entered data and has a response code to modify Access'
behaviour after the event is dealt with. In the event
handler routine, you can open a data entry form to
capture any additional data for the new list entry, then
tell Access that the new data has been added. It will
then handle the requery and selection of the list entry
automatically. The code samples provided are pretty
straightforward and explicit. If you are still having
difficulties after trying this route then come back to
the newsgroup with any further questions.

Keith
 
Back
Top