Solved

Passing selectionformula to report...

Posted on 2004-03-25
8
497 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
[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
  • 4
  • 4
8 Comments
 
LVL 101

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 101

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 101

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 101

Expert Comment

by:mlmcc
ID: 10710486
Glad I could help

mlmcc
0

Featured Post

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

617 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