Set cn = CreateObject("ADODB.Connection")
With cn
.Provider = "Microsoft.ACE.OLEDB.12.0"
.ConnectionString = "Data Source=" & ThisWorkbook.Path & "\" & ThisWorkbook.Name & ";" & _
"Extended Properties=""Excel 12.0 Xml;HDR=YES"";"
.Open
End With
'---Running the SQL Select Query---
Sql = "SELECT '', AgentName, Pax, SellingFare, Pax * SellingFare, 455, 455 * Pax FROM [db_SALES$] WHERE Trx = 'Selling' AND FlightDateGo = #" & TglTerbang & "#"
Set rs = cn.Execute(Sql)
'Sheets("Report").Range("A2").CopyFromRecordset rs
' Do
' output = output & rs(0) & ";" & rs(1) & ";" & rs(2) & vbNewLine
' Debug.Print rs(0); ";" & rs(1) & ";" & rs(2)
' rs.Movenext
' Loop Until rs.EOF
' MsgBox output
'---Clean up---
rs.Close
cn.Close
Set cn = Nothing
Set rs = Nothing