Public Function gStr(fld As String)
Dim rs As New ADODB.Recordset
Dim strSQL As String
strSQL = "SELECT DM FROM TABDM WHERE KT='" & fld & "'"
With rs
.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockReadOnly
Do While Not .EOF
gStr = gStr & .Fields(0) & ","
.MoveNext
Loop
.Close
End With
Set rs = Nothing
End Function
SELECT KT.KTID, KT.KFXM, gStr([KTID]) AS 表达式1
FROM KT;