We help IT Professionals succeed at work.

Passing selectionformula to report...

tounghuat
tounghuat asked
on
Medium Priority
525 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
Comment
Watch Question

Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
try

.RecordSelectionFormula = SelectionFormula

mlmcc

Author

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
Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
What references have you included for Crystal?

What is the rest of the code?

mlmcc

Author

Commented:
Will reply on monday...

huat

Author

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.
Senior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
mlmcc.. Thanks a lot. Thats really helps. :D

huat.....
Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
Glad I could help

mlmcc
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.