qazwsxedc
asked on
Cystalreport
i create the cystal report in VB, and a lot of records store inside the table. assume that i have one MDB file content 1 table name "table" and 5 records stored inside this table from number 1 to 5. so how to search through the particular record that i specified and print to cystal report. for example, when i choose the record 3 then how the cystal report gonna to search through ? what's the command or functions using in VB ?
ANYONE KNOW WHAT'S THE BEST SITE FOR CYSTAL REPORT GUIDE ?
ANYONE KNOW WHAT'S THE BEST SITE FOR CYSTAL REPORT GUIDE ?
ASKER
sorry, it doesn't work, error message "Report not found". PLEASE HELP
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try this and see if it work
Dim CriteriaStr As String
CriteriaStr = "{Table.id} = " & Text1.Text
frmMain.CrystalReport1.Dat aFiles(0) = gstrFullDatabaseName
frmMain.CrystalReport1.Rep ortFileNam e = gstrReportDirectory & "\MyReport.rpt"
frmMain.CrystalReport1.Rep laceSelect ionFormula (CriteriaStr)
frmMain.CrystalReport1.Act ion = 1
'======CLEANING THE REPORT SETTING========
frmMain.CrystalReport1.Rep laceSelect ionFormula ("")
frmMain.CrystalReport1.Dat aFiles(0) = ""
frmMain.CrystalReport1.Rep ortFileNam e = ""
'========================= ========== =======
Note: Always clean up at the end of setting.
Dim CriteriaStr As String
CriteriaStr = "{Table.id} = " & Text1.Text
frmMain.CrystalReport1.Dat
frmMain.CrystalReport1.Rep
frmMain.CrystalReport1.Rep
frmMain.CrystalReport1.Act
'======CLEANING THE REPORT SETTING========
frmMain.CrystalReport1.Rep
frmMain.CrystalReport1.Dat
frmMain.CrystalReport1.Rep
'=========================
Note: Always clean up at the end of setting.
Also made an Access database with a simple table in it called "Table" with two fields in it, ID (auto-number) and "Description" (Text). Put five records in.
Code...
--------------------------
Option Explicit
Private Sub Command1_Click()
Dim i As Integer
CrystalReport1.SelectionFo
CrystalReport1.ReportFileN
CrystalReport1.DiscardSave
CrystalReport1.WindowState
i = CrystalReport1.PrintReport
If (i <> 0) Then
MsgBox CrystalReport1.LastErrorSt
End If
End Sub
------------
Tip: use crystal to create your selection formula and then cut and paste it into VB, pluggin-in your values where needed.