What's the best way to refresh a list box in MS Access? The way I have tried it doesn't seem to work :-/
This is my current method (onClick event of a button开发者_如何学JAVA on the same form):
Me.orders.Requery
I have also tried
orders.Requery
and
Forms!currentOrders.orders.Requery
but none of them seem to refresh the list box's contents - I see no new items, even though I know that there are some. Closing off the form, and then re-opening it does show the new items, however.
You could try and requery the form first and then requery the listbox
You need to use a temporary textbox, then your listbox will refresh automatically. The following solution worked for me. (I don't know why, but using direct value from searchbox didn't work for me.) i have used no button. For instant search:
- a textbox where you actually type. its name "Finder"
- a textbox where you save the searching string temporarily. its name "Search".
- a listbox where you show result. its name "lstResults"
(NB: also to mention, the query, uses the textbox named "Search"; which is our temporary textbox.)
code:
Private Sub Finder_Change() ' "on change" event of "Finder" box
Me.search = Me.Finder.Text ' save the typed text in another textbox and use from there for query (otherwise it might not work)
Me.lstResults.Requery ' update listbox "lstResults" on any change
End Sub
精彩评论