Solved

Passing selectionformula to report...

Posted on 2004-03-25
8
493 Views
Last Modified: 2012-05-04
Hi,
Need your helps again.
I'm using vb6 and crystal report 9 and with microsoft access as database.
i'm able to print and preview the report using the application that i've created. The problem comes when i added in the code to pass the selectionformula to report. If i add in directly the selectionformula to the report in design time, i can print or preview the report. This problem comes only if i add in selectionformula using coding.
code as below:

SelectionFormula = "{Member.MbCode}=11111"            
With CrxReport
      .SelectionFormula = SelectionFormula
      .Destination = crptToWindow
      .WindowParentHandle = Preview.hWnd
      .PrintReport
End With

Is there any problem with my code?? plz help...

huat
0
Comment
Question by:tounghuat
  • 4
  • 4
8 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 10684401
try

.RecordSelectionFormula = SelectionFormula

mlmcc
0
 

Author Comment

by:tounghuat
ID: 10684701
hi,
yup.. i've try that before.
when i use the code, it gives a msg "Method or Data Member Not Found".
should i need to include anything??
huat
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 10693635
What references have you included for Crystal?

What is the rest of the code?

mlmcc
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:tounghuat
ID: 10694411
Will reply on monday...

huat
0
 

Author Comment

by:tounghuat
ID: 10701542
HI,
My code as below:

--------------------------------------------------------
Public cn As New ADODB.Connection
Public rs As New ADODB.Recordset

Public Sub main()
cn.Open "Provider=Microsoft Jet 4.0 OLE DB Provider;Data Source=" & App.Path & "\Library.mdb;Jet " _
           & "OLEDB:Database Password=" & Chr(10) & "admin"
form1.Show
End Sub

-----------------------------------------------------

Private Sub Command1_Click()
Dim SelectionFormula As String
SelectionFormula = "{Member.MbBarCode}='11111'"
With CrxReport
    .ReportFileName = App.Path & "\RegMem.rpt"
    .Formulas(0) = "header = 'Registered Member Listing'"
    .SelectionFormula = SelectionFormula
    .Destination = crptToWindow
    .PrintReport
End With
End Sub

I only drag in the crystal report control to the form.
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 30 total points
ID: 10701648
Try it this way

Add a reference
Crystal Reports X ActiveX Design Runtime Library (CRAXDRT.dll)

Add to the form with the viewer
Public crApp As CRAXDRT.Application
Public crRpt As CRAXDRT.Report

Private Sub Command1_Click()
Dim SelectionFormula As String
SelectionFormula = "{Member.MbBarCode}='11111'"
'
'   Open report
'
    Set crApp = New CRAXDRT.Application

    Set crRpt = crApp.OpenReport(App.Path & "\RegMem.rpt", 1)
    crRpt.RecordSelectionFormula = SelectionFormula
'
'   Set flags for CRViewer
'
    crRpt.MorePrintEngineErrorMessages = False
    crRpt.EnableParameterPrompting = False
    crRpt.DiscardSavedData

'
' Set the viewer's report source to the Report object
'
    Me.rptCRViewer.ReportSource = crRpt
    Me.rptCRViewer.ViewReport


End Sub

mlmcc
0
 

Author Comment

by:tounghuat
ID: 10709676
mlmcc.. Thanks a lot. Thats really helps. :D

huat.....
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 10710486
Glad I could help

mlmcc
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Crystal Report Error 14 84
Insert timestamp data field of max summary 8 41
Crystal - variable evaluate after with criteria 4 53
Crystal Reports Subreport details 16 57
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

813 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

8 Experts available now in Live!

Get 1:1 Help Now