?
Solved

Cystalreport

Posted on 1998-08-03
4
Medium Priority
?
186 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 80 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

764 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