|
2#
楼主 |
发表于 2009-6-2 23:04:35
|
只看该作者
自己重新修改了一下代码如下:可是运行时还是出现错误提示。是否SQL语句不能执行交叉表查询?
Private Sub RNDAcctSplitByProj_Click()
Dim MthExpName As String
Dim Db As DAO.Database
Dim qdf As DAO.QueryDef
Dim StrSql As String
MthExpName = Me.ActExpTabByMth
Set Db = CurrentDb
If MsgBox("是否要拆分实际月份研发费用", vbYesNo, 警告") = vbNo Then Exit Sub
StrSql = "SELECT [MthExpName].Reference, [MthExpName].Acct, AccountsDescription.AcctDescription, [MthExpName].Activ, FROM " _
& "AccountsDescription INNER JOIN MthExpName ON AccountsDescription.Acct = [MthExpName].Acct " _
& "TRANSFORM Sum ([MthExpName].PeriodActivity) AS PeriodActivity " _
& "GROUP BY [MthExpName].Reference, [MthExpName].Acct, AccountsDescription.AcctDescription " _
& "HAVING ((([MthExpName].Activ) Like '6*'))" _
& "PIVOT Format([MthExpName].Activ)"
Set qdf = Db.CreateQueryDef("RNDAcctsSplitByProject", "StrSql")
DoCmd.OpenQuery "RNDAcctsSplitByProject", acViewPivotTable, acEdit
Exit_RNDAcctSplitByProj_Click:
Exit Sub
Err_RNDAcctSplitByProj_Click:
MsgBox Err.Description
Resume Exit_RNDAcctSplitByProj_Click
End Sub |
|