Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

insert into from list

Posted on 2013-02-01
5
Medium Priority
?
309 Views
Last Modified: 2013-02-01
i have a list generated from a form and need to insert 1 record per value.
eg (10,20,30) how would I insert this into tableA with the values added into the field Quantity.

any ideas to get me started?
0
Comment
Question by:Shawn
  • 2
  • 2
5 Comments
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 total points
ID: 38843215
You'll have to run each INSERT statement separately:

Dim i As Integer
Dim arr() As String

arr  = Split(YourList, ",")

For i = 0 to Ubound(arr)
  Currentdb.Execute "INSERT INTO TableA(Quantities) VALUES(" & arr(i) & ")"
Next i
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 38843216
the question is: what exactly do you need help with?
* inserting "a" record?
* splitting the list into values so you could run the insert one by one?
0
 
LVL 1

Author Comment

by:Shawn
ID: 38843229
* splitting the list into values so you could run the insert one by one?
yes :)
0
 
LVL 85
ID: 38844195
The code I provided will work to do that.
0
 
LVL 1

Author Closing Comment

by:Shawn
ID: 38844744
thanks Scott. Worked great.
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question