我有这段代码:
If Len(Me.Text9.Value & vbNullString) = 0 Then
sSQL = "SELECT [Ra 1080] as [civil] FROM civil where main=" & Forms![PDS Main Form]![Main Table ID] & " ORDER BY ID"
Set rs = db.OpenRecordset(sSQL)
rs.MoveFirst
Do Until rs.EOF
Text9.Value = Text9.Value + rs!civil + ", "
rs.MoveNext
Loop
Set rs = Nothing
End If
如果你运行查询,它将返回3条记录cs1.5,cs1.3,cs1.9
运行代码文本框只会返回cs 1.3,cs 1.9,
答案 0 :(得分:0)
不确定使用MoveFirst会造成麻烦,请尝试此代码。看看它是否有效。
If Len(Me.Text9.Value & vbNullString) = 0 Then
sSQL = "SELECT [Ra 1080] As [civil] FROM civil WHERE main = " & _
Forms![PDS Main Form]![Main Table ID] & " ORDER BY ID"
Set rs = db.OpenRecordset(sSQL)
Do While Not rs.EOF
Text9.Value = Text9.Value & rs!civil & ", "
rs.MoveNext
Loop
Set rs = Nothing
End If
刚刚删除了.MoveFirst和其他一些简单的修改。