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

x
?
Solved

Changing Crystal Report ParameterField in VB

Posted on 2002-03-15
8
Medium Priority
?
373 Views
Last Modified: 2009-12-16
Hi,

I have a Crystal Report which uses a stored procedure for its data source.  The stored
procedure has a parameter, TARGETDATE, which I am obtaining from the user and
trying to pass to Crystal.

I open a Crystal Report and set some values:
    With crwRpt
        .FormulaFields(1).Text = "'" & sDate1 & "'"
        .RecordSelectionFormula = sSel2
        .ParameterFields(0) = sSel1
    End With

The sSel1 variable is:  TARGETDATE;2002-03-15;TRUE

Even though this is the format stated in another EE question, I get the infamous 'Type mismatch'
error on the ParameterFields statement.  I am using VB6 and Crystal 8.

Any ideas?

Ken

   
0
Comment
Question by:kenspencer
[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
  • 2
  • 2
8 Comments
 
LVL 3

Author Comment

by:kenspencer
ID: 6869286
Forget to mention -- TARGETDATE is a string.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 6869327
The date passed must be a real date type.


Try
sSel1 = "TARGETDATE;" & date(2002,03,15) & ";TRUE"

good luck
mlmcc
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 6869332
Forget to mention -- TARGETDATE is a string.
Missed that part.  The value must be a string
Try
sSel1 = "TARGETDATE;'2002-03-15';TRUE"

good luck
mlmcc
0
Technology Partners: 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!

 

Accepted Solution

by:
bill02 earned 100 total points
ID: 6869358
Make sure you have the crystal reports designer and runtime library reference included in your project and use this code it should work just change the_Crystal_report to your report name(crwRpt) and the parameter name to your parameter name good luck

Dim paramdefs As CRAXDRT.ParameterFieldDefinitions
Dim paramdef As CRAXDRT.ParameterFieldDefinition
Set paramdefs = The_Crystal_Report.ParameterFields
For Each paramdef In paramdefs
 With paramdef
    Select Case .ParameterFieldName
    Case "YOURREPORTFIELDNAME"
        .SetCurrentValue sSel1
    End Select
 End With
Next


0
 
LVL 3

Author Comment

by:kenspencer
ID: 6876653
mimcc:
   Tried enclosing date with single quotes -- still got type mismatch error.

bill02:
   I had seen this example in one of the Crystal manuals, but was hoping that a
simple assignment statement would work without going the 'long' way.  However,
I will try it.

Ken
0
 
LVL 3

Author Comment

by:kenspencer
ID: 6877150
Going the long route seems to have had some effect, since I do not get the 'Type Mismatch' error.  The parameter field name (in Crystal) was  {?TARGETDATE}.  However, it appears that the report starts to run before I get:

   Run-time error '20534':
   Error detected by database DLL.

I could not find this error code in the DB2 reference, so I am still needing assistance.  
I will post another question in the DB2 forum for that, but will hold this one open for any other suggestions.

It was supposed to be a simple report ...

Ken

0
 
LVL 3

Author Comment

by:kenspencer
ID: 6877308
Well, success at last.  Going the long route (mentioned above), I had to use:

   .SetCurrent Value  <just the date string>         'example: 2002-03-18

Thanks for the suggestions.  Since the short method did not work and the long method did, I will award points to bill02.  However, since I had seen that methodology in the Crystal Reports Developer's Guide prior to even asking this question, and that the string value required was just the date portion of sSel1, I will award a lower grade.

Thanks for everyone's suggestions.

Ken
0
 

Expert Comment

by:bill02
ID: 6878706
If you found the answer before asking you shouldn't have asked a answer that answers your question and does what you ask should recieve a higher than a c grade im taken back by that anyways thanks for the points
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

721 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