设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1195|回复: 0
打印 上一主题 下一主题

[查询] 这题难,....求助!!!!!

[复制链接]
跳转到指定楼层
1#
发表于 2009-6-24 20:25:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
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
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-12-1 19:26 , Processed in 0.087970 second(s), 24 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表