Solved

VB 5 and crystal report 8.5

Posted on 2004-04-18
7
885 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem to skip loop 6 57
VBA open file from excel cell 4 42
Getting warning: You are about to delete 1 row(s) 9 49
VB6 - Scroll Mouse wheel on Picturebox 13 44
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

809 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