Click to See Complete Forum and Search --> : Listbox problem pls help
hlieu
May 16th, 2000, 02:23 AM
Hi All,
How do I save multiple items(at once)in the list box to an Access table?
I Have a listbox contained more than one customer names, I would like to write all the names to the access table at one click of the button.
Thanks
YoungBuck
May 16th, 2000, 11:38 AM
Here is a simple way to do it using SQL:
Private Sub SaveList()
Dim db as Database
Dim strSQL as String
dim i as Integer
Set db = DBEngine.OpenDatabase("C:\MyDBPath.mdb")
For i = 0 to (List1.ListCount - 1)
'assuming that the name of the table is Customers
'and the name of the field to accept the data is CustomerName
strSQL = "INSERT INTO Customers (CustomerName) VALUES ('" & List1.List(i) & "');"
Call db.Execute(strSQL)
next i
db.Close
End Sub
of course you will have to customize some of the parameters to match your database (i.e. the path of the actual database, the names of the table and field to insert the new names).
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.