0

I need short vba code to convert ms access table field to comma delimited string variable

T1.F     to    'A','123','008','A'
A
123
008
A

1 Answer 1

1

The following will get your desired string in s :

Dim s as String, rs as Recordset

s = " Select [F] from [T1] "
Set rs = CurrentDb.OpenRecordset(s)
s = ""
While Not rs.EOF
    s = s & "'" & rs(0) & "',"
    rs.moveNext
Wend
s = Left(s,Len(s) - 1)
rs.close
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! it worked, but can it be shorter like SPLIT(rs," ',' ") or SPLIT([T1].[F1]," ',' ")?
As far as I know, you can't do something like that to a recordset. I'm pretty sure you'll have to iterate to get the result.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.