I am trying to create crystal report 11 with VB6. But it seen like during the execution of code, the sql statement was ignored (line 12). And the report listed out everything. Below is my code.
Dim rs As ADODB.Recordset Dim strSQL As String Set Report = New CR_DriverCommission_Rpt Set rs = New ADODB.Recordset strSQL = "SELECT SALES_ID, DOC_DATE FROM BTU_SALES_15 WHERE SALES_ID LIKE 'D%'" rs.Open strSQL, cn, adOpenDynamic, adLockBatchOptimistic With Report .Database.SetDataSource rs .PaperOrientation = crDefaultPaperOrientation .PaperSize = 2 .DiscardSavedData End With With CRViewer1 .EnableDrilldown = False .DisplayGroupTree = False .DisplayTabs = False .EnableRefreshButton = True .ReportSource = Report .ViewReport .Zoom (100) End With Set Report = Nothing rs.Close Set rs = Nothing
Anybody has any idea what went wrong? I am losing hair solving this. :'(
Thank in Advance.