Series numbers to Table (1 Viewer)

Gismo

Registered User.
Local time
Today, 11:24
Joined
Jun 12, 2017
Messages
1,298
Hi All,

a user copies information from PDF to a form
the information in the control could be a series of serial numbers separated by n comma

I want to take the series number and populate it in a new table, each serial number to a new record

Sample: 4354, 6456, 6543, 7634, 7345, 7643,6533

to: 4354
6456
6543
7634
7345
7643
6533

how would I accomplish this?
The string could have anything from 1 to 50 serial numbers
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:24
Joined
May 7, 2009
Messages
19,169
use split() function:

dim strTest as string
dim var as variant
dim v as variant

strTest = "4354, 6456, 6543, 7634, 7345, 7643,6533"

var = split(strTest, ",")
for each v in var
if len(trim(v & ""))>0 then
currentdb.execute "insert into tablename (fieldname) select " & v
end if
next
 

Gismo

Registered User.
Local time
Today, 11:24
Joined
Jun 12, 2017
Messages
1,298
use split() function:

dim strTest as string
dim var as variant
dim v as variant

strTest = "4354, 6456, 6543, 7634, 7345, 7643,6533"

var = split(strTest, ",")
for each v in var
if len(trim(v & ""))>0 then
currentdb.execute "insert into tablename (fieldname) select " & v
end if
next
the strtest is only a sample, how do i code this to any sequence of number entered by the user?
 
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 09:24
Joined
Sep 21, 2011
Messages
14,037
the strtest is only a sample, how do i code this to any sequence of number entered by the user?
Have you even tested it to see how it works :(
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:24
Joined
Sep 21, 2011
Messages
14,037
yes, i have
getting errors on
# currentdb.execute "insert into tablename (fieldname) select " & v #
Ahh, you are meant to replace fieldname and tablename with your field and table names? :rolleyes::rolleyes:
I would have probably used Values instead of Select

Google the syntax for the INSERT SQL statement.
 

Gismo

Registered User.
Local time
Today, 11:24
Joined
Jun 12, 2017
Messages
1,298
Ahh, you are meant to replace fieldname and tablename with your field and table names? :rolleyes::rolleyes:
I would have probably used Values instead of Select

Google the syntax for the INSERT SQL statement.
i did replace with my table and field name
seems to be fine

only thing is, the range of sequence numbers are never the same so i can not have it fixed in the code
how do I code to select from the form where entered?

strTest = "4354, 6456, 6543, 7634, 7345, 7643,6533" serial numbers must be selected from the form
 
Last edited:

Gasman

Enthusiastic Amateur
Local time
Today, 09:24
Joined
Sep 21, 2011
Messages
14,037
I'll leave arnelgp to explain, but you should really start making some effort in understanding the code that is given to you, :( given the time you have been here and the number of posts you have made?
 

Gismo

Registered User.
Local time
Today, 11:24
Joined
Jun 12, 2017
Messages
1,298
got it, thank you for the support, always much appreciated
 

Users who are viewing this thread

Top Bottom