Edit Formula field in Crystal Report using VB

Posted on 2004-10-22
Last Modified: 2008-02-01
I have Crystal Report 8.5, VB6. I have this Crystal report with a simple formula, which does.

stringVar str := "";

The value for str should come from the VB form.
Once I get the user input, how can I pass the value of str to Crystal using VB.

I saw many places, CrystalReport1.Formulas(0) = blah blah..

Question by:girishsarma
    LVL 42

    Accepted Solution

    The best approach is to create a parameter on your report and then use the parameter in your formula:

    {CrystalLoss.Category} = {?YourParameter};

    Here's a working example of how to pass a parameter so you can just copy & paste the code into your application:


    LVL 13

    Expert Comment

    Looks like you're using the OCX(?).

    Are you trying to change the Record Selection Formula at runtime, or just a regular formula field?

    To replace the Record Selection Formula:
    CrystalReport1.ReplaceSelectionFormula ("{CrystalLoss.Category} = '" & str & "'")

    Or, as frodoman suggested, if you create a parameter in the report, you'd pass it like:
    CrystalReport1..ParameterFields(1) = "ParamName;" & str & ";true"


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    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…
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    934 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

    18 Experts available now in Live!

    Get 1:1 Help Now