Solved

Cystalreport

Posted on 1998-08-03
4
182 Views
Last Modified: 2010-05-03
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 ?  
0
Comment
Question by:qazwsxedc
  • 2
4 Comments
 
LVL 2

Expert Comment

by:percosolator
ID: 1467647
Ok.  Taking your example, I made a form with a textbox, command button and crystal control on it, using the default names that VB supplies.  

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.SelectionFormula = "{Table.id} = " & Text1.Text
    CrystalReport1.ReportFileName = "C\t1\report1.rpt"
    CrystalReport1.DiscardSavedData = True
    CrystalReport1.WindowState = crptMaximized
   
    i = CrystalReport1.PrintReport
   
    If (i <> 0) Then
   
        MsgBox CrystalReport1.LastErrorString

    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.

0
 

Author Comment

by:qazwsxedc
ID: 1467648
sorry, it doesn't work, error message "Report not found". PLEASE HELP
0
 
LVL 2

Accepted Solution

by:
percosolator earned 20 total points
ID: 1467649
If you are getting the message "Report not found", that means that the path and report name are invalid.

Make sure that the crystal report property "ReportFileName" points exactly to your report's path and name.

Crystal1.ReportFileName = "C:\MyPath\MyReport.Rpt"

0
 

Expert Comment

by:Trang
ID: 1467650
Try this and see if it work

Dim CriteriaStr As String

CriteriaStr = "{Table.id} = " & Text1.Text

frmMain.CrystalReport1.DataFiles(0) = gstrFullDatabaseName
frmMain.CrystalReport1.ReportFileName = gstrReportDirectory & "\MyReport.rpt"
frmMain.CrystalReport1.ReplaceSelectionFormula (CriteriaStr)
frmMain.CrystalReport1.Action = 1

  '======CLEANING THE REPORT SETTING========
      frmMain.CrystalReport1.ReplaceSelectionFormula ("")
      frmMain.CrystalReport1.DataFiles(0) = ""
      frmMain.CrystalReport1.ReportFileName = ""
 '==========================================

Note: Always clean up at the end of setting.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now