Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refreshing List Box after Update 1

Status
Not open for further replies.

jaredc

Programmer
Jun 28, 2002
43
0
0
GB
Hi all,

Really need some help. I've got a relational DB setup although getting the forms to work is proving rather difficult.

I have one form that has a combo box on it. The values for this come from a table. What the user needs to be able to do is to add values to the table and then have the combo box dynamically refreshed so that they can then select the values they've added to it. So what I've done is put a button on the form that opens another form allowing them to amend the data. However, once they've added data and return to the orignal from the combo box is not updated.

What I have used is a trigger on an update of the 2nd forms text box to requery the combo box on the other form like such:

Private Sub TextX_AfterUpdate()

Forms!frm_Items.Form!Location_Name.Requery

End Sub

Where the original form is called frm_Items and the combo box is called Location_Name.

Problem is that it doesnt work. What I need to know (as I started trying to do this 5 months ago and now know why I gave up) is how to reference an item on a different form and get it to refresh. Or any ideas for a workaround.

Please help
 
Well, your code should do that, but, when you open forms in popup, modal or with acDialog, then requeries aren't always available.

My way of doing this, is to open the form to change the underlying table in dialog mode, and then requery the list/combo or whatever afterwards:

docmd.openform "frmForUpdating",,,,,acDialog
me!Location_Name.Requery

The acDialog stops code excecution in your current form until the other form is closed.

HTH Roy-Vidar
 
Another method of doing this is to set the LimitToList property of the combobox to yes...then use the NotInList event to open the form to add the new data....

With the proper setup, the combobox is automatically requeried and the newly entered item is even preselected for you...

If you need help with the setup of the NotInList event, search these forums or let me know...

****************************
When the human body encounters disease it raises its temperature making it uncomfortable not only for the body but also for the disease. So it global warming the Earth's way of saying we are not wanted?

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Thanks for the replies.... I used the first one and it worked straightaway - saved me lots of time and effort. Thanks also for the second suggestion, I will certainly look into that when I've got a bit more spare time and when I've sorted the problem below.

I've actually now got a problem that follows on from my original one. How do you refresh the values in a subform?

I'm trying to refresh a combo box that is located within a subform in a similar manner to how I did it before. Instead of just refreshing the combo box on the form using Me!item_name.Requery I've now got to refresh the subform's combo box. Can I use Me! or do I use Forms! or something to reference it.... Sorry I dont know access that well

I've tried to refresh the whole subform using Me!Subform_name.requery but this doesnt work. Can you not refresh a subform in this manner?

Any advice/suggestions like before would be great

Thanks :)
 
Roy,
You've helped me again. I wanted to requery a form after returning to it from another (pop-up) form and had tried putting the requery command on just about every event you could think of (open, load, dirty, activate, etc., etc.) but nothing worked. I had no idea it was as simple as just putting the requery command after the command to open the pop-up form. Thank you very much. Star from me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top