Solved

Cystalreport

Posted on 1998-08-03
4
183 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MsgBox 2 61
VBA filters 2 71
How to compare ms sql hashbytes results within vb6 5 98
Problem to With line 4 75
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…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…

726 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