MS Access vba逗号从字段分隔的字符串

时间:2014-09-17 05:45:30

标签: string vba field

我需要短的vba代码来将ms访问表字段转换为逗号分隔的字符串变量

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

1 个答案:

答案 0 :(得分:0)

以下内容将在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