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

Refreshing a list box

P: n/a
Hi,

I have an unbound listbox in my main form that is used for reference only.
If I want to add a record to the table that this list box displays, I open a
seperate form to enter a new record to the table.

What I would like, is for the list box in the main form to refresh after the
new record is saved. Currently, I need to close and reopen the main form
that contains the listbox in order to see the new record.

Thanks

Tim
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
POut the following code in the Click event of the Close button on the
'separate form':
Forms!NameOfMainForm.Requery

"Tim Graichen" <Tg*******@neo.rr.com> wrote in message
news:lt*******************@fe2.columbus.rr.com...
Hi,

I have an unbound listbox in my main form that is used for reference only.
If I want to add a record to the table that this list box displays, I open a seperate form to enter a new record to the table.

What I would like, is for the list box in the main form to refresh after the new record is saved. Currently, I need to close and reopen the main form
that contains the listbox in order to see the new record.

Thanks

Tim

Nov 13 '05 #2

P: n/a
Hi Tim,
The simplest way to do this is on the "Close" event of the form you use to
add/update the table used as the recordsource for the listbox put:
Private Sub Form_Close()
if isloaded("frmListBox") = True then
form_frmListBox.lboRecords.requery
endif
end sub

"IsLoaded" is a standard function that checkes to see if the form passed in
is open:
Public Function IsLoaded(ByVal strFormName as _ String) as Integer
Isloaded = Application.CurrentProject.AllForms _(strFormName).isloaded
End Function

Regards
Barry

"Tim Graichen" <Tg*******@neo.rr.com> wrote in message
news:lt*******************@fe2.columbus.rr.com...
Hi,

I have an unbound listbox in my main form that is used for reference only.
If I want to add a record to the table that this list box displays, I open a seperate form to enter a new record to the table.

What I would like, is for the list box in the main form to refresh after the new record is saved. Currently, I need to close and reopen the main form
that contains the listbox in order to see the new record.

Thanks

Tim

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.