Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / February 2006

Tip: Looking for answers? Try searching our database.

Listbox doesn't update on Requery

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark - 17 Feb 2006 05:55 GMT
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
Wayne Morgan - 17 Feb 2006 06:21 GMT
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

Signature

Wayne Morgan
MS Access MVP

> Hello.
>
[quoted text clipped - 16 lines]
> Thanks
> -Mark
Mark - 17 Feb 2006 07:13 GMT
>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
Allen Browne - 17 Feb 2006 07:19 GMT
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?

Signature

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.

>>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
[quoted text clipped - 5 lines]
> 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.
Mark - 17 Feb 2006 07:27 GMT
Sorry Allen, it was a goof on my part. My database insert
code wasn't doing what I thought it was doing.

-Mark
Mark - 17 Feb 2006 07:26 GMT
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
Wayne Morgan - 17 Feb 2006 17:15 GMT
> This is a listbox control, not a combobox.

Sorry, bad reading.

Signature

Wayne Morgan
MS Access MVP

>>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
[quoted text clipped - 8 lines]
> Thanks
> -Mark
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.