How to refresh a listbox

access83

Registered User.
Local time
Today, 16:44
Joined
Apr 25, 2012
Messages
22
Hi All,

I'm having trouble updating the contents of a listbox. I have a form and users select a file, a sql server stored procedure is then called and the filepath is saved to a table on the sql server and the filename is then added to the listbox. This works fine and the listbox refreshes and displays the added file name after each file is added. However, I have a problem when I try and delete from the listbox. A user will select the item from the listbox they want to delete and click 'delete'. A sql server stored procedure is called and the selected entry in the sql server table is deleted, then the contents of the table (minus the record just deleted) are returned to access and this is the source of the listbox. I return the results of the sql server stored procedure into a recordset and make this the source of the listbox. However, the listbox doesn't reflect these changes until the form is closed and reopened. I've tried..

Code:
Me.listbox_name.requery

but it doesn't work.
Code:
me.listbox_name.RemoveItem
doesn't work either because the 'Row source type' is 'table/query'

Does anyone have any suggestions on how to refresh the listbox without having to close the form?

Thanks in advance :)
 
For bound forms in A2007, I need to update the form RecordSource property to the same as it is already set to in order for a call to Refresh to pick up the fact that records changed in the RecordSource the form was already bound to. So try adding setting the RecordSource just ahead of the call to Refresh and see if that solves the problem for you as well.

P.S. Or specifically Requery in your case.
 

Users who are viewing this thread

Back
Top Bottom