Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB 5 and crystal report 8.5

Posted on 2004-04-18
7
Medium Priority
?
890 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
[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
  • 3
7 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 375 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 101

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 101

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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. 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

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…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

715 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