Update a Listbox from a Dataentry Form

SpiritedAway

Registered User.
Local time
Today, 08:27
Joined
Sep 17, 2009
Messages
97
Update a Listbox

Hi,

I have a form, FRMTrack that holds a Listbox called [Documents] - the data is drawn from a query, QRYTRACK -

When I double click an entry in the Listbox it takes me to the correct record where I can then modify the existing record or add a new record. This form is called FrmData.

On the onclose event I have this bit of code:

Private Sub Form_Close()
Forms![FrmTrack].Requery
End Sub

Thinking that when I close FrmData, the modified or new record would be added or changed in my Listbox, but this is not the case.

From what I've identified is that the table, tblTrack is being updated with changes but not QRYTrack which is where Listbox draws its row source data from.

Can anyone tell me how, after modifying or adding data in FrmData, for it to automatically update to show these changes in my Listbox as well.

Thanks

SpiritedAway
 
Last edited:
Requerying a form does not cause cause a control such as a Combobox or Listbox to requery. You'll have to explicitly requery the Documents Listbox.
 
An easy way to do this is to paste the rowsource sql into the tag property of listbox.

Then on the on close event of the form

Code:
Forms("FRMTrack")("Documents").RowSource = Forms("FRMTrack")("Documents").Tag
 
Thanks missingling for responding,

Could you give me some ideas about how I would do this?

Thanks

SpiritedAway
 
Thanks DCrake for responding I will try what you suggested - and let you know how I get on.

Thanks

SpiritedAway
 
Hi,

I pasted the rowsource SQL of QRYTRACK into the tag property of my list box as suggested and it does work updating changes i make to existing records in the listbox.

But when I want to add a new record from FRMData the listbox does not update with the new record, nor is the new record showing in QRYTRACK but it does show in the table, tblTrack.

I've got the first part done, updating changes, but how do I get the Listbox to update with new records?

Thanks

SpiritedAway
 

Users who are viewing this thread

Back
Top Bottom