Full Version: Textbox to Array
UtterAccess Forums > Microsoft® Access > Access Forms
RedlightG20
I have a textbox that users will use to enter multiple lines of serial numbers.
R00001
FR00002
FR00004
FR00018
FR00035
etc..
From there, I would like each line from the text box to be written into perhaps an array, which would then go to the serial number table and create new records using these serials. How can I place each line into an array, or perhaps is there another way to read each line and make a new record?
fkegley
This sounds like an unnecessarily roundabout way to do this. If you are going to store the serial numbers in a table, would it be possible to use a form or subform that is bound to the serial numbers table?
pbaldy
I'm with Frank, but if you need it, the Split function should be able to do it.
RedlightG20
I gotcha. Thanks for the replies. So what would be the best method to do this?
Create a subform as you said, maybe in datasheet view, which would allow the user to paste in additional records? But I cannot seem to paste each line so that it shows up correctly in datasheet form. Perhaps my settings are wrong.
pbaldy
Are you pasting single values or the whole list? If the whole list, you're probably stuck with the single textbox and parsing out the values with the Split function.
fkegley
So this is an existing list, is that right? Then you would want to allow the users to add new values to this list once you have created it?

The Split function, as blank has already posted, would be the way to break the existing list up into the parts, it will require some sort of separator character between each item in the list though. But if that is so, it should work just fine.

Then once you have split the items using code, you can put more code that puts the existing items into a table.

Base the subform on the new table, the users can then add new values to the list, or use the existing values if that is what they need.

Added: Yes, that works just fine.
Edited by: fkegley on Wed Sep 3 15:00:12 EDT 2008.
pbaldy
I've been called a lot of things, but "blank" is a new one. You must be a mind reader. dazed.gif
fkegley
A thousand pardons, Paul! Mea Culpa! Mea Culpa! Mea Culpa! I sentence myself to 100 lashes with a wet noodle!
bviously, I meant to fill in your name before I posted. Equally obviously, I forgot to do it. My age is catching up with me.
Sorry about that, again, Paul! No insult intended.
pbaldy
LOL! No offense taken here Frank, so take it easy with that noodle. I was just cracking a joke.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.