Source Code lanjutan:
Private Sub cmdGenerate_Click()
On Error GoTo Err_optDet
Dim sSQL As String
Dim sPageLevelPivot As String
Dim sColLevelPivot As String
Dim sRowLevelPivot As String
Dim sDataPivot As String
Dim ExistFile
Dim rstemp As ADODB.Recordset
Screen.MousePointer = vbHourglass
'Bangun Sql mu disini
'Sebelum membuatnya, koneksikan data tersebut
' Set rstemp = New ADODB.Recordset
' With rstemp
' .CursorType = adOpenStatic
' .CursorLocation = adUseClient
' .LockType = adLockReadOnly
' .ActiveConnection = Active connection to the data source
' .Open
' End With
'Diskoneksikan dari sumber data tersebut
Set rstemp.ActiveConnection = Nothing
'menghapus laporan sebelumnya, jika ada data yang sama
ExistFile = Dir("C:\Report.xls")
If ExistFile <> "" Then Kill ("C:\Report.xls")
'Ini adalah bidang recorset untuk pengelompokan
sPageLevelPivot = "0"
sColLevelPivot = "1"
'sRowLevelPivot = "2345"
sRowLevelPivot = "45"
sDataPivot = "6"
Call GenerateReport(rstemp, sPageLevelPivot, sColLevelPivot, _
sRowLevelPivot, sDataPivot, "C:\Report.xls")
Screen.MousePointer = 0
Exit_optDet:
Set rstemp = Nothing
Exit Sub
Err_optDet:
Screen.MousePointer = 0
Resume Exit_optDet
End Sub
Bingung dengan hasilnya seperti apa? silahkan download programnya Laporan Pivot VB