listbox help

05-26-2002, 10:13 AM
How would I write items from a listbox to a Access database.

Items are ItemID, Item, Description, Line Price.
From Listbox1.

Ales Zigon
05-26-2002, 10:28 AM
Does this represent the name of the fields in your table (ItemID, Item, Description, Line Price) and the ListBox contains values for these fields in the same order?

If so, you can loop thru the list and add values to the table by its field index.
Something like this:
Sub DBAddItem()
Dim n%
For n = 0 To List1.ListCount - 1 'loop thru the list
'open your database connection and add items
With MyDataBase
.Fields(n).Value = List1.List(n)
End With
Next n
End Sub

If you don't know how to work with databases, go and look in the database forum section. Thre are lots of examples.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum