views:

40

answers:

2

i have a string like this

something = "something, something1, "something2, something else", something3"

i need it to be read into a table like this:

field1 = "something"
field2=  "something1"
field3 = "something2, something else"
field4 = "something3"

please notice that the double quotes in the something string signified that the string inside the quotes is to be placed in one field

anyone know how to do this with an insert into statement or some other way? the answer can be purely sql or can be vba with sql.

thanks!

+1  A: 

Replace the character sequence , " with something the pipe sign for example and then use that as field separator.

Raj
`something = "something, something1, "something2, something else", something3"``tempLine = Replace(something, "" ,", "^")``lines = Split(templine, "^")`Loop through the lines array and create the necessary insert statements.I would have included the VBA code but I'm a .NET programmer now and I suddenly can't recall if VBA has statements like `for each string curLine in Lines`` ' insert statements``Next`
Raj
+1  A: 

You should be able to use single quotes within $something to cause Access to treat the entirety of the quoted section as an atomic unit:

something = "something, something1, 'something2, something else', something3"
VeeArr
u da man thanks a lot bingo
I__