Solved

VB 5 and crystal report 8.5

Posted on 2004-04-18
7
883 Views
Last Modified: 2010-05-18
Hi all,

I've made a crystal report rpt file which churns out reports using an odbc connection with the db.
problem is, i have no idea how to let users enter variables (dates, to be exact) .

so i looked around and decided to use VB 5 (yes i know it's freakin old) as a front end to choose a date , and then pass the variables to the report .
I've added a crystal report control on the form and i can do a CrystalReport1.PrintReport .

how do i pass the variables to the rpt file, and how do i get them into the report's sql ? this is my first time using crystal report so i'm pretty lost.

also, i noticed that to refresh the data in the report , i need to key in the password again. how do i define the db connection and the password/username in vb ?
0
Comment
Question by:shenlong_wc
  • 4
  • 3
7 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 125 total points
ID: 10865566
0
 

Author Comment

by:shenlong_wc
ID: 10936493
tried the links, 1 and 3 were unsuitable because i only have vb 5 and CR8.5

looking up the web, i now find that the code in vb is

crptReport.ParameterFields(0)="Broker;TR04;true"

but do i create that "Broker" variable and use it in the selection sql ?
0
 

Author Comment

by:shenlong_wc
ID: 10936500
i mean how do i create and use that variable in CR ?
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 100

Expert Comment

by:mlmcc
ID: 10967624
In CR
Open the report
Display the field popup or Click INSERT --> PARAMETER
Right click on PARAMETER
Select NEW
Name - Broker

It can now be used from VB

Did you try the methods.  I know they are listed as for CR9 but the RDC didn't change that much with CR9 so the method should work.  Or are you using the OCX?
What references did you add to the VB program?

mlmcc
0
 

Author Comment

by:shenlong_wc
ID: 10992783
Hi,

there is no INSERT --> PARAMETER in CR 8.5 =P

what i did was goto the report wizzard, under fields i created another a formula (eg. dateFrom ) . inside this formula, i declared a variable of the same name and returned it.

varString dateFrom := "";
dateFrom;

so i do this for every variable i need. they can be used in other portions of the report by using {@dateFrom}. not sure if this is be best way to do it, but it works for me.

now in VB i cannot use crptReport.ParameterFields(0)="Broker;TR04;true" anymore, rather i use crptReport.Formula(0).text="1/1/2004" (i'm not infront of the compiler now, so my syntax is gonna be off. explore abit yourself ^_^)

the problem to this method is that you cannot specify the variable name . if you have more than 1 variable in CR , then you have to trial and error to find out which .Formula(x) is the one you wanna use. big hassle there.

well, until i can find "parameter" option in CR , this is all i have. it works but is a pain in the a$$ to work with =p
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 10993168
There is a better way to find the formulas than trial and error.  The formula names are available to the applicationinan array and you can search for the name.  This eliminates the trial and erro and also ensures if the report changes the formula passing still works.

        For k = 1 To crRpt.FormulaFields.Count
            If (UCase$(crRpt.FormulaFields(k).Name) = UCase$(strFormulaNameToFind))) Then
                  crRpt.FormulaFields(k).Text = "ValueForTheFormula"
                  Exit For
            End If
        Next k

Glad I could help

mlmcc
0
 

Author Comment

by:shenlong_wc
ID: 11012949
oh ok, thanks !
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

708 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

13 Experts available now in Live!

Get 1:1 Help Now