please can somone instruct me how to make my access app save the contents of a listbox into a table.
thanks
Printable View
please can somone instruct me how to make my access app save the contents of a listbox into a table.
thanks
If this is in Access VBA, then create a new ADODB Command object. Create your SQL INSERT statement by reading all the items in the listbox, you may end up with several INSERT statements. Then for each insert statements, execute it using the command object against your database.
Code:Dim i As Long
Dim sSQL As Long
For i = 0 to List1.ListCount - 1
sSQL = "INSERT INTO yourtable (fieldname) VALUES ('" & List1.List(i) & "') "
yourcommandobject.Execute sSQL
Next
Hack when you say
yourcommandobject.Execute sSQL
what does the "yourcommandobject" mean, what should i put here? and will this (hacks example) work the same for a textbox with multiple lines of text?
i appreciate your assistance.
The reason for the loop is to handle multiple lines. Multiple lines, in fact, are assumed.
How to you connect to your database?
If you are using ADO, then you have a connection object.
It is what you declared as: As ADODB.Connection
cheers thanks hack ill give it a shot