|
Private Sub Command43_Click()
Dim rsm As ADODB.Recordset
Dim mysql As String, aq As String, AAA总计 As String
Dim tyu As String
Set rsm = New ADODB.Recordset
'AAA总计是新增的字段名
If IsNull(Me.Combo12) Then Exit Sub
tyu = Combo12.Value
mysql = " TRANSFORM Sum(末归类明细.AAA)
AS " & "AAA之总计" & _
" SELECT 末归类明细.日期, 末归类明细.凭证号, Sum(末归类明细.AAA) AS " & " AAA总计 " & _
" FROM
末归类明细" & _
" WHERE
总账科目 ='" & tyu & "'" & _
" GROUP BY 末归类明细.日期, 末归类明细.凭证号 " & _
" PIVOT 末归类明细.明细科目"
'" INTO aq " & _
rsm.Open mysql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
mm = rsm.RecordCount
MsgBox "表 '" & mm, vbInformation
上述代码是创建一个有参数的交叉表查询,测试通过了,我的问题是把这个有参数的交叉表查询命名,再以此查询生成表,表名是组合框选定的值,有什么好法???求!!!!!,帮帮则个。这个任务在SQL中很好解决,用代码不知行不?????
Dim rsmm As ADODB.Recordset
Dim mysqln As String, aqq As String
Set rsmm = New ADODB.Recordset
mysqln = " SELECT mysql.日期,mysql.凭证号,mysql.AAA总计 " & _
" INTO aqq " & _
" FROM mysql"
rsmm.Open mysqln, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
DoCmd.Rename Me.Combo12 & "明细帐", acTable, "aqq"
End Sub |
|