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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add items into listbox

Status
Not open for further replies.

nuglorious

IS-IT--Management
Nov 29, 2002
24
SG
i have a unbound listbox which user add items into the listbox. is it possible to update this items into the table itself after inputting as i have tried many ways but failed.
[cry]
 
[tt]
Hello, Nu Glorious:

One of the differences between a list box and a combo box is that the combo box allows you to enter a value that is not on the list...the list box does not.

You can change your list box to a combo box and then write the code to allow the user to add a new value to the list.

Another difference is that in the list box you can make more than one selection...in the combo box you may select only one value.

I hope this helps. [glasses] Gus Brunston, using Access2000 Intermediate skills.
 
What gusbrunston said is true, as far as it goes--the user can't add items directly to the list box by typing something into it.

But perhaps you mean you are using code to add items to the list box. If your list box's Row Source Type is set to "Table/Query", you could do it by adding the row data directly to the underlying table using a DAO or ADO recordset, and then call the list box's Requery method to reload the list. Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
hi Rick
as what you have said so its possible to do that way right?Btw, I would like to try out your method and see if this will work. If possible, could you help me to provide the necessary codes and guide me with this. I'm appreciate for your help..thks
 
I can help you with DAO, but I don't know ADO. Here are the basic steps for DAO:
1. Using Tools|References on the menu (only visible when you are in a code module), add a reference to the Microsoft DAO object library if it's not there already. (Help file topic: Set References to Type Libraries.)
2. Using variables of type Database and Recordset, open a recordset over the table to be updated. Add the row to the table. Close the recordset, and set the variables to Nothing. (Help file topics: Database object, Recordset object, OpenRecordset method, AddNew method, Update method, Close method. Be sure to look at the example code.)
3. Call the list box's Requery method. (Help file topic: Requery method of ListBox control.)

If coding is new to you, the Northwind and Solutions databases (the latter is in the Developer's Edition of Access/Office) will be very helpful. Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top