Dear teman-teman semua

Saya mencoba menulis coding berikut untuk menggabungkan 3 buah tabel. Tapi
hanya berjalan baik kalau hanya 2 tabel saja yang digabungkan. Terserah
tabel yang mana dari yang tiga tersebut yang digabungkan. Selalu gagal kalau
menggabungkan ketiga tabel tersebut. Pesan errornya "General ODBC error".
Mohon bantuan teman-teman bagaimana solusinya untuk bisa menggabungkan
ketiga tabel tersebut.



> Private Sub cmdRefresh_Click()
> Dim baris As String
>     Dim conn As String
>
>     conn = "ODBC;DSN=Excel Files;DBQ=" & ActiveWorkbook.FullName &
> ";DefaultDir=" & ActiveWorkbook.Path &
> ";DriverID=790;MaxBufferSize=2048;PageTimeout=5"
>     With ActiveSheet.QueryTables.Add(Connection:=conn,
> Destination:=Range("A3"))
>         baris = "select Date, Invoice, SPPA, CustCode, CustArea, CustName,
> Bird, Kg, NetSalesPerKg, null as `Notes`, 0 as `Credit`, kg * NetSalesPerKg
> as `Debit` from LB where (NetSalesPerKg > 0) "
>         baris = baris + " union all select
> Date,null,null,CustCode,CustArea,CustName,0,0,0,RefCOH,COHAmount,0 from COH
> where (COHAmount > 0) "
>         baris = baris + " union all select
> Date,null,null,CustCode,CustArea,CustName,0,0,0,RefCIB,CIBAmount,0 from CIB
> where (CIBAmount > 0) order by date "
>         .CommandText = baris
>         .Name = "DataGabungan"
>         .FieldNames = True
>         .RowNumbers = False
>         .FillAdjacentFormulas = False
>         .PreserveFormatting = True
>         .RefreshOnFileOpen = True
>         .BackgroundQuery = True
>         .RefreshStyle = xlOverwriteCells
>         .SavePassword = False
>         .SaveData = True
>         .AdjustColumnWidth = False
>         .RefreshPeriod = 0
>         .PreserveColumnInfo = True
>         .Refresh BackgroundQuery:=False
>     End With
> end sub
>

Kirim email ke