Dear All,
I have a code to get data from sql server. I would like to have the comments as the last part of my exported data, but I cannot get. Where ever I change that line the rest of the data comes out nothing. Any help?
Thanks in advance
Baha
I have a code to get data from sql server. I would like to have the comments as the last part of my exported data, but I cannot get. Where ever I change that line the rest of the data comes out nothing. Any help?
Thanks in advance
Baha
Code:
Sub PMAster5()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim lastrow As Long
Dim cel As Range
Dim TD As Double
Dim TD2 As Double
Dim Conn As ADODB.Connection, intColIndex As Integer
TD = Range("trddate1").Value
TD2 = Range("trddate2").Value
Sheets("CustomerData2").Select
Sheets("CustomerData2").Range("A2:X" & Rows.Count).ClearContents
Set TargetRange = Range("A2")
Set Conn = New ADODB.Connection
Conn.Open "driver={SQL Server};" & _
"server=CustDB1074;database=Reporting_ODS;"
Set RecSet = New Recordset
RecSet.Open "SELECT TotalSales.CustId,TotalSales.Lname +' '+ TotalSales.Fname, " & _
"TotalSales.Table_Id, TotalSales.Game_Date_No, TotalSales.Time_In, TotalSales.Time_Out,TotalSales.Hours, TotalSales.ShopId, " & _
"CASE " & _
"WHEN Convert(int,TotalSales.ShopId) IN (45,46,47) THEN 'PEARL' WHEN Convert(int,TotalSales.ShopId) IN (29) THEN 'DIAMOND' " & _
"WHEN Convert(int,TotalSales.ShopId) IN (12,15,16,18,31) THEN 'Xclub' " & _
"WHEN Convert(int,TotalSales.ShopId) IN (212,218,219) THEN 'Sales_CASH' WHEN Convert(int,TotalSales.ShopId) IN (70,71) THEN 'GMadim' " & _
"Else 'NONASSIGNED' END, " & _
"CASE TotalSales.ZoneCode " & _
"WHEN 'GoldRiver HighSociety' THEN 'HC' WHEN 'GoldRiver Main Floor' THEN 'GMF' WHEN 'GoldRiver Main Floor Podium' THEN 'GMF Pd' WHEN 'GoldRiver Pearl Room' THEN 'Pearl R'" & _
"WHEN 'GoldRiver Ruby' THEN 'Ruby' WHEN 'GoldRiver Diamond' THEN 'Diamond' WHEN 'GoldRiver UpperClass Cash' THEN 'UC_Cash' " & _
"Else 'NONASSIGNED' END, " & _
"TotalSales.GameType,TotalSales.CashIn, TotalSales.ChckIn, TotalSales.MarkerIn, TotalSales.TotalIn, TotalSales.AvgBet, TotalSales.Estwl, " & _
"TotalSales.Trip_Id, TotalSales.Theo, TotalSales.SalesComment " & _
"FROM Reporting_ODS.TG.TotalSales TotalSales " & _
"WHERE TotalSales.SalesComment like '%nnp%' And TotalSales.Time_Out>=1 And TotalSales.Game_Date_No>='" & TD & "' And TotalSales.Game_Date_No<='" & TD2 & "'" & _
"ORDER BY TotalSales.CustId ASC", Conn, , , adCmdText
TargetRange.CopyFromRecordset RecSet
RecSet.Close
Set RecSet = Nothing
Conn.Close
End Sub