|
Private Sub Command6_Click()
Dim Qdf As DAO.QueryDef
Dim varI As Variant
Dim strGrp As String, strSum As String
Dim strSQL As String, strGrpFldName As String
Dim bb
For Each varI In Me.List0.ItemsSelected
strGrp = strGrp & Me.List0.ItemData(varI) & ","
Next
For Each varI In Me.List2.ItemsSelected
strSum = strSum & "Sum(" & Me.List2.ItemData(varI) & ") As 总" & _
Me.List2.ItemData(varI) & ","
Next
bb = "a"
If strGrp = "" Then
MsgBox "请选择分组项目"
Exit Sub
ElseIf strSum = "" Then
MsgBox "请选择统计项目"
Exit Sub
End If
Set Qdf = CurrentDb.QueryDefs("c")
strSum = Left(strSum, Len(strSum) - 1)
strGrpFldName = Left(strGrp, Len(strGrp) - 1)
strSQL = "select " & strGrp & strSum & " from " & bb & " group by " & strGrpFldName
strSQL = "select * from " & strSQL 不加此句运行没有任何问题,但增加此句就错了,请错在那里,如何改?
Qdf.SQL = strSQL
Me.Child4.SourceObject = "查询.c"
Qdf.Close
Set Qdf = Nothing
End Sub |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|