Hai... im using crystal report n
vb 6.0. my database is access. im facing problem in displaying data in crystal report.
my code are as below:
Private Sub Command2_Click()
Dim strSQL As String
strSQL = "select ComplaintNo from ComplaintView where PersonKeyInICNo = '" & Trim(Text1.Text) & "'"
With adoComplaintView
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\database.mdb" & ";Mode=Read;Persist Security Info=False"
.RecordSource = strSQL
.CommandType = adCmdUnknown
.Refresh
End With
With adoComplaintView.Recordset
If Not .RecordCount = 0 Then
g_RunReport1 Me, "Report", "Complaint Report - by Person Enter.rpt", strSQL, , , , lvFmlAry, , , True
End If
End With
End Sub
Public Sub g_RunReport1(poform As Form, sTitles As String, _
sReportFile As String, _
sSql As String, _
Optional sSortField As String, _
Optional sSortField1 As String, _
Optional sSortField2 As String, Optional fml As Variant, Optional psGraphOption As String, Optional psDest As String, Optional psZoom As Boolean)
Dim i As Integer
Dim lsDate As Date
On Error GoTo ErrHandler
lsDate = Now()
With poform.CrystalReport1
' Report properties Setting - Fixed
If psDest = "P" Then
.Destination = crptToPrinter
Else
.Destination = crptToWindow
End If
.WindowState = crptMaximized
.DiscardSavedData = 1
.Connect = App.Path & "\database.mdb"
If fml(0) <> "NULL" Then
For i = LBound(fml) To UBound(fml)
.Formulas(i) = fml(i)
Next i
End If
.WindowTitle = sTitles
.ReportFileName = App.Path & "\Report\" & sReportFile
.SQLQuery = sSql
.WindowShowPrintSetupBtn = True
If sSortField <> "" Then
.SortFields(0) = "+" & sSortField
End If
If sSortField1 <> "" Then
.SortFields(1) = "+" & sSortField1
End If
If IsNull(sSortField2) Then
.SortFields(2) = "+" & sSortField2
End If
If IsMissing(psGraphOption) = False Then
.GraphOptions(0) = psGraphOption
End If
.Action = 0
If psZoom = False Then
'Set Zoom level to 6 7%
.PageZoom (67)
End If
End With
Exit Sub
ErrHandler:
If err.Number <> 0 Then
Screen.MousePointer = 0
MsgBox err.Number & " - " & err.Description, vbInformation, "Error"
End If
End Sub
is there any problem with my code?
i wan to generate the report which the PersonKeyInICNo = Trim(Text1.Text). but the report generated display all the record in the ComplaintView.
pls help. thanks