The code that i uesed :
Private Sub View_Report()
'=========================================================================
' Pass The Record Selection Formula To The Report Proramatically
' Give You More Flexibility To Play With The Report
' Note The Syntax Of That Formula
' Little Different of SQL
'========================================================================
If Txt_No.Text <> "" Then
Formula = daksf.SelectCommand.CommandText = "SELECT Itemnum ,Glnum,Cat,CostCo,Docnum,Description,Amount FROM kashef where Invoicenum = '" & Txt_No.Text & "' "
End If
'========================================================================
'=========================================================================
' These assrayes used to pass any parameter fields
ReDim Arr_FPF(0) : Arr_FPF(0) = "Afrina Trading & Construction"
'=========================================================================
View_RPT_All("RPT_CustAll.rpt", 1)
'========================================================================
End Sub
Private Sub View_RPT_All(ByVal RD As String, ByVal PapOr As Integer)
' '=========================================================================
' ' This Function help in getting reportd from any where
' ' you will not be worry about the path of the report
' ' just pass this pass to the function
' '=========================================================================
Dim OTable As CrystalDecisions.CrystalReports.Engine.Table
Dim OTableLogInfo As CrystalDecisions.Shared.TableLogOnInfo
Dim RPT As New ReportDocument
Dim I, J As Integer
Dim CON As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Afrina\Afrina\bin\dbaf.mdb;User Id=admin;Password=;")
' '=========================================================================
RPT.Load("..\RPT_CustAll.rpt")
RPT.Refresh()
RPT.PrintOptions.PaperOrientation = PapOr
For Each OTable In RPT.Database.Tables
OTableLogInfo = OTable.LogOnInfo
OTable.ApplyLogOnInfo(OTableLogInfo)
Next OTable
'=========================================================================
' to pass the report parameter fields
'For I = 0 To Arr_FPF.Length - 1 : RPT.SetParameterValue(I, Arr_FPF(I)) : Next
''=========================================================================
'' Pass the selection record formula
If Formula <> "" Then RPT.RecordSelectionFormula = Formula
'=========================================================================
CRViwer.ReportSource = RPT
CRViwer.Zoom(2) ' Fit the report to the page width
'==============================================================