Solved

VB 5 and crystal report 8.5

Posted on 2004-04-18
7
884 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb script Microsoft Word tables portion of based on bookmark, count and add rows 1 48
Passing a Text Box name to a Sub 6 75
TT Auto Dashboard 13 83
VB6 ListBox Question 4 33
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 …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

920 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

12 Experts available now in Live!

Get 1:1 Help Now