Passing parameter from VB to Crystal Reports

Hi Experts-

I have a variable as a 'Single' datatype in my VB program.  I'm trying to pass it as a parameter to my Crystal Report.  The parameter has been set up as a 'Number' datatype in Crystal.  I get a type mismatch error when the program tries to pass the variable to the report parameter.  Crystal only has Currency and Number numeric datatype choices.  What do I have to do to get these two datatypes to match up?  

Looking forward to your responses!
MariaHaltAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ebolekCommented:
why dont you convert the single to integer and then send it to Crystal in VB.
0
MariaHaltAuthor Commented:
I'm using the Single datatype because there's decimal involved.
0
ebolekCommented:
create a forumulain the report and convert the single variable to currency

currencyvar var :=$({databasefield});
var
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

MariaHaltAuthor Commented:
The problem is that the report will not accept the single variable at all, not as a number or currency parameter.  

If I convert the single variable to a string in VB and change the parameter datatype in the report to string, it accepts it, string to string.  The problems with this is 1.) Formatting (for some reason numbers in Crystal do not right align the same as strings) and 2.) Have to create a new Crystal Formula field, converting the string parameter to number and 3.) Update my formuals to use the new field instead of the parameter I've already established.  

There must be a simple way to pass a numeric value to Crystal.  
0
mlmccCommented:
What language?  What version of Crystal?

mlmcc
0
MariaHaltAuthor Commented:
VB6 and Crystal 8.5
0
MariaHaltAuthor Commented:
I'm increasing the point value to get more responses.
0
ebolekCommented:
did you try to convert it to currency usinf this formula:
create a forumulain the report and convert the single variable to currency

currencyvar var :=$({databasefield});
var
0
MariaHaltAuthor Commented:
I'm passing a parameter, not a database field.  

The Crystal report will not accept the Single datatype variable.  I changed the parameter to currency and am getting the same error, type mismatch.  Let me rephrase my original question, How does one pass a numeric variable to a Crystal report parameter of type number or currency?
0
vidruCommented:
What means are you using to access the Crystal Print Engine: API, RDC, OCX, other?  And can you post the code you're trying?

-dave
0
MariaHaltAuthor Commented:
Short version of VB code...

Private Sub cmdGenerateReports_Click()
Dim sinGFCredits As Single
Dim sinGPCredits As Single

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Code assigning sinGFCredits & sinGPCredits, then...
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Set crApplication = CreateObject("CrystalRuntime.application")
Set crReport = crApplication.OpenReport(strReportName)
crReport.Database.SetDataSource rstDb, 3, 1
Set crParameters = crReport.ParameterFields
 'Loop through the parameters fields in the report by name and pass variable
For Each crParameter In crParameters
      Select Case crParameter.ParameterFieldName
            Case "GFCredits"
                 crParameter.SetCurrentValue sinGFCredits
            Case "GPCredits"
                 crParameter.SetCurrentValue sinGPCredits
      End Select
 Next crParameter

I use this same bit of code for passing strings to string type parameters in Crystal with no problem.  Don't know why numbers are problematic.  TIA
0
vidruCommented:
Apparently, Crystal doesn't like Singles, but this should work for you:

For Each crParameter In crParameters
      Select Case crParameter.ParameterFieldName
            Case "GFCredits"
                 crParameter.SetCurrentValue Val(sinGFCredits)
            Case "GPCredits"
                 crParameter.SetCurrentValue Val(sinGPCredits)
      End Select
 Next crParameter

-dave
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MariaHaltAuthor Commented:
It worked!  Thank you!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.