Solved

Cystalreport

Posted on 1998-08-03
4
184 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 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