|
-
May 31st, 2008, 01:39 AM
#1
Thread Starter
Hyperactive Member
save listbox contents to a table
please can somone instruct me how to make my access app save the contents of a listbox into a table.
thanks
-
May 31st, 2008, 04:37 AM
#2
Re: save listbox contents to a table
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.
-
May 31st, 2008, 04:52 AM
#3
Re: save listbox contents to a table
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
-
Jun 5th, 2008, 06:31 AM
#4
Thread Starter
Hyperactive Member
Re: save listbox contents to a table
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.
-
Jun 5th, 2008, 12:56 PM
#5
Re: save listbox contents to a table
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
-
Jun 5th, 2008, 06:21 PM
#6
Thread Starter
Hyperactive Member
Re: save listbox contents to a table
cheers thanks hack ill give it a shot
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|