why Sales>Comments cannot be displayed?

baha17

Board Regular
Joined
May 12, 2010
Messages
183
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

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
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Do some of your comments records contain nnp?

WHERE TotalSales.SalesComment like '%nnp%'
 
Upvote 0
You're not being very explicit, what exactly isn't displaying? Are no records being returned? Are columns missing etc..
 
Upvote 0
The problem is the last column does not display the data.all the other column has the data but not the last one
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top