Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 503
  • Last Modified:

Passing selectionformula to report...

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
tounghuat
Asked:
tounghuat
  • 4
  • 4
1 Solution
 
mlmccCommented:
try

.RecordSelectionFormula = SelectionFormula

mlmcc
0
 
tounghuatAuthor Commented:
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
 
mlmccCommented:
What references have you included for Crystal?

What is the rest of the code?

mlmcc
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
tounghuatAuthor Commented:
Will reply on monday...

huat
0
 
tounghuatAuthor Commented:
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
 
mlmccCommented:
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
 
tounghuatAuthor Commented:
mlmcc.. Thanks a lot. Thats really helps. :D

huat.....
0
 
mlmccCommented:
Glad I could help

mlmcc
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now