Solved

Passing selectionformula to report...

Posted on 2004-03-25
8
495 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
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.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Exporting Crystal report withh dynamic image in C# 5 80
Conditional Text in Crystal 4 59
Exclude some records from totals 10 63
Crystal Reports 2013 25 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…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

713 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