|
-
Mar 30th, 2006, 02:07 AM
#1
Thread Starter
Junior Member
[RESOLVED] Add Listbox Items into a table
How can I add items in a Listbox into an SQL table??
-
Mar 30th, 2006, 02:15 AM
#2
Frenzied Member
Re: Add Listbox Items into a table
you can use a for loop and an sql statement executed in ado for that purpose
VB Code:
if List1.ListCount > 0 then
Dim a as Long
for a = 0 to List1.ListCount - 1
cn.execute "insert into statement here to insert the data from the listbox to the db"
Next
End If
On error goto Trap
Trap:
in case of emergency, drop the case...
****************************************
If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option. if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar
-
Mar 30th, 2006, 06:54 AM
#3
Thread Starter
Junior Member
Re: Add Listbox Items into a table
This doesn't seem to work
Actually I hav to add the raw materails used in a product
I'm doing something as follows:
rs.AddNew
rs!prod_name = txtname
rs!raw material = lstRM.List(lstRM.ListIndex)
rs.Update
I know this code is wrong.
Please suggest some code that is appropriate with this method
rs.AddNew
rs!prod_name = txtname
rs!raw material = lstRM.List(lstRM.ListIndex)
rs.Update
Thx..
-
Mar 30th, 2006, 06:57 AM
#4
Re: Add Listbox Items into a table
just put this into a loop
VB Code:
For i = 0 To lstRM.ListCount -1
rs.AddNew
rs!prod_name = txtname
rs!raw material = lstRM.List (i)
rs.Update
Next
just give a try and post if anything else
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Mar 30th, 2006, 07:21 AM
#5
Thread Starter
Junior Member
Re: Add Listbox Items into a table
For i = 0 To lstRM.ListCount -1
rs.AddNew
rs!prod_name = txtname
rs!raw material = lstRM.List (i)
rs.Update
Next
this is generating an error '3265'
-
Mar 30th, 2006, 07:47 AM
#6
Thread Starter
Junior Member
Re: Add Listbox Items into a table
Sorry I solved that error.
But this method only seems to add the last item in the list.
Is there any way of adding all the items in the list into the table??
-
Mar 30th, 2006, 09:00 AM
#7
Thread Starter
Junior Member
Re: Add Listbox Items into a table
Thx every1 for ur help.
I found the solution.
I thought I should post it.
Dim rm As String
Dim a as Integer
For a = 0 To list1.ListCount-1
rm = rm & list1.List(a)
Next
rs!RM = rm
rs.Update
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
|