By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,657 Members | 1,045 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,657 IT Pros & Developers. It's quick & easy.

Listbox doesn't update on Requery

P: n/a
Hello.

I have a listbox whose rowsource is set to a saved query (call it
"qry_customer_list.") When I add customers to my database, I call the
listbox Requery method so that the listbox will display the customers that I
added. Unfortunately, the listbox display does not change. If I close the
form and reload it, then the listbox will show the new customers.

Any suggestions on how to fix this?

Someone suggested there might be a timing issue where my listbox Requery
happens before the database insert is completed. I tested this by adding a
command button to call the listbox Requery method. I tried the command
button numerous times after adding a customer, and the customer still did
not show up in the listbox.

Suggestions?

Thanks
-Mark
Feb 17 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
I take it that you are adding an entry because you went to the listbox and
the entry wasn't there. If that is the case, manually type the entry into
the listbox and let the NotInList event activate. In this event, you can add
the item you just typed in to a new record in the listbox's recordset or
pop-up a form to fill out the rest of the record is that is needed. Once
you've added the record, use the command

Response = acDataErrAdded

to tell the listbox that new data has been added to the recordset for its
RowSource. The listbox will automatically update itself.

Example:
http://www.mvps.org/access/forms/frm0015.htm

--
Wayne Morgan
MS Access MVP
"Mark" <no****@thanksanyway.org> wrote in message
news:W_******************************@w-link.net...
Hello.

I have a listbox whose rowsource is set to a saved query (call it
"qry_customer_list.") When I add customers to my database, I call the
listbox Requery method so that the listbox will display the customers that
I added. Unfortunately, the listbox display does not change. If I close
the form and reload it, then the listbox will show the new customers.

Any suggestions on how to fix this?

Someone suggested there might be a timing issue where my listbox Requery
happens before the database insert is completed. I tested this by adding a
command button to call the listbox Requery method. I tried the command
button numerous times after adding a customer, and the customer still did
not show up in the listbox.

Suggestions?

Thanks
-Mark

Feb 17 '06 #2

P: n/a
"Wayne Morgan" <co***************************@hotmail.com> wrote:
I take it that you are adding an entry because you went to the listbox and
the entry wasn't there. If that is the case, manually type the entry into
the listbox and let the NotInList event activate.


This is a listbox control, not a combobox. I am adding data to the database,
and that data would be returned by the listbox's underlying rowsource.
I want the listbox to refresh and display the new data. That doesn't
happen, not even when I execute the listbox's Requery method.

Thanks
-Mark
Feb 17 '06 #3

P: n/a
Mark, what is the timing of this?

How are you adding record's to the list box's RowSource table?
- Executing an Append query?
- Adding to a Recordset? - ADO or DAO?
- Entering into a Form?

Are you sure the record has been written before the requery? For example, is
it still in the form (not saved) when the Requery happens?

Does adding a DoEvents give it the chance to catch up?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Mark" <no****@thanksanyway.org> wrote in message
news:aq********************@w-link.net...
"Wayne Morgan" <co***************************@hotmail.com> wrote:
I take it that you are adding an entry because you went to the listbox and
the entry wasn't there. If that is the case, manually type the entry into
the listbox and let the NotInList event activate.


This is a listbox control, not a combobox. I am adding data to the
database,
and that data would be returned by the listbox's underlying rowsource.
I want the listbox to refresh and display the new data. That doesn't
happen, not even when I execute the listbox's Requery method.

Feb 17 '06 #4

P: n/a
"Mark" <no****@thanksanyway.org> wrote:

Sorry, the problem is not what I thought it was. Apparently my code
wasn't applying the update to the database, so there was nothing
new for the listbox to retrieve when I executed its Requery method.

Thanks for your help.
-Mark
Feb 17 '06 #5

P: n/a
Sorry Allen, it was a goof on my part. My database insert
code wasn't doing what I thought it was doing.

-Mark
Feb 17 '06 #6

P: n/a
> This is a listbox control, not a combobox.

Sorry, bad reading.

--
Wayne Morgan
MS Access MVP
"Mark" <no****@thanksanyway.org> wrote in message
news:aq********************@w-link.net...
"Wayne Morgan" <co***************************@hotmail.com> wrote:
I take it that you are adding an entry because you went to the listbox and
the entry wasn't there. If that is the case, manually type the entry into
the listbox and let the NotInList event activate.


This is a listbox control, not a combobox. I am adding data to the
database,
and that data would be returned by the listbox's underlying rowsource.
I want the listbox to refresh and display the new data. That doesn't
happen, not even when I execute the listbox's Requery method.

Thanks
-Mark

Feb 17 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.