PDA

View Full Version : Is it possible for a new item to be automatically updated or deleted on a list box?



wedd
01-20-2011, 02:19 AM
Hi, I have a list box of locations on my database form. On another area of my form I have a section where new locations can be added, as well as existing locations can be deleted. Is it possible with the use of vba, macro,or expression etc for the list box to automatically display a new location in the listbox when it has been added on that particular section of the form and vice versa if a location has been deleted that the location will be automatically deleted from the listbox on the section of the form that displays all the locations. Can this be done? If so, how can this be done? Do you have any examples where this has been performed?



Thanks for your contributions :friends:

CreganTur
01-20-2011, 07:24 AM
I imagine that your list is being populated by a table or query in your database. When a user wants to add a location have the button they click run a SQL Update query to add the value into your table and then call your form's ReQuery method. This will refresh your form so it pulls the most recent information from your database, which means it will show the newly added value.

hansup
01-20-2011, 09:59 AM
A Requery of the entire form will work. However, a side effect is the user may lose her position in the form's record set, unless you bookmark her position before the Requery and move to the bookmarked record afterwards. Also for a complex form, the time required to Requery may be unacceptable.

Instead of Requery of the form, you can just Requery the list box control.

Me.YourListBoxName.Requery

wedd
01-30-2011, 12:23 PM
Thanks, hansup!