Data Access Worldwide Forums
 

Go Back   Data Access Worldwide Forums > Products > Crystal Reports

Notices

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 17-Sep-2009, 03:56 PM
ivansc ivansc is offline
Member
 
Join Date: Jun 2009
Posts: 43
Default Passing Values to Parameters

I want to pass values from VDF to the report parameters (rather than use Crystal's parameter selection screen).
I get the parameters with this:
Code:
Get ParamObjects of horeport to hoParamObjects
Move (SizeOfArray(hoParamObjects)) to iCount
For iItem from 0 to (iCount-1)
   Get ComParameterFieldName of hoParamObjects[iItem] to sParamName
   Get ComPrompt             of hoParamObjects[iItem] to sPrompt
   Get ComValue of hoParamObjects[iItem] to svalue   //always empty
   Showln iItem " : " sParamName " - " spromp " - " svalue
Loop
but i can't find the function to set the values.
Here i've found a thread (garret mott / steven wong) from feb 2006, with this solution:
Code:
//forum Crystal
//16-Feb-2006, 08:25 PM  
//Steven Wong 
//Re: Passing Values to Parameters 
#Replace PE_PF_REPORT_NAME_LEN 128
#Replace PE_PF_NAME_LEN 256
#Replace PE_PF_PROMPT_LEN 256
#Replace PE_PF_VALUE_LEN 256
#Replace PE_PF_EDITMASK_LEN 256
#Replace PE_PF_NUMBER 0
#Replace PE_PF_CURRENCY 1
#Replace PE_PF_BOOLEAN 2
#Replace PE_PF_DATE 3
#Replace PE_PF_STRING 4
// Used by PESetNthParameterField
Type PEParameterFieldInfo
Field PEParameterFieldInfo.StructSize as Word
Field PEParameterFieldInfo.ValueType as Word
Field PEParameterFieldInfo.DefaultValueSet as Word
Field PEParameterFieldInfo.CurrentValueSet as Word
Field PEParameterFieldInfo.Name as Char PE_PF_NAME_LEN
Field PEParameterFieldInfo.Prompt as Char PE_PF_PROMPT_LEN
Field PEParameterFieldInfo.DefaultValue as Char PE_PF_VALUE_LEN
Field PEParameterFieldInfo.CurrentValue as Char PE_PF_VALUE_LEN
Field PEParameterFieldInfo.ReportName as Char PE_PF_REPORT_NAME_LEN
Field PEParameterFieldInfo.NeedsCurrentValue as Word
Field PEParameterFieldInfo.isLimited as Word
Field PEParameterFieldInfo.MinSize as Char 8
Field PEParameterFieldInfo.MaxSize as Char 8
Field PEParameterFieldInfo.EditMask as Char PE_PF_EDITMASK_LEN
Field PEParameterFieldInfo.isHidden as Word
End_Type // PEParameterFieldInfo
 
External_Function32 PESetNthParameterField "PESetNthParameterField" CRPE32.DLL ;
   Integer printJob Integer parameterN Pointer parameterInfo Returns Integer
 
External_Function32 PEGetNthParameterField "PEGetNthParameterField" CRPE32.DLL ;
   Integer printJob Integer parameterN Pointer parameterInfo Returns Integer
 
Procedure Set NthParameterField Integer iParameterN Integer iType Integer horeport String sValue 
String sPEParameterFieldInfo sBuffer sParameterN
Pointer pPEParameterFieldInfo
Integer iPrintJob iResult
//Get PrintJob to iPrintJob
Move horeport to iPrintJob  //i think horeport=Printjob ...is it ok?
FillType PEParameterFieldInfo With 0 to sPEParameterFieldInfo
GetAddress of sPEParameterFieldInfo to pPEParameterFieldInfo
Put PEParameterFieldInfo_Size to sPEParameterFieldInfo At PEParameterFieldInfo.StructSize
Move (PEGetNthParameterField(iPrintJob,iParameterN,pPEParameterFieldInfo)) to iResult
Put iType to sPEParameterFieldInfo At PEParameterFieldInfo.ValueType
Put 1 to sPEParameterFieldInfo At PEParameterFieldInfo.DefaultValueSet
Put 1 to sPEParameterFieldInfo At PEParameterFieldInfo.CurrentValueSet
Case Begin
    Case (iType = PE_PF_NUMBER)
       //Put_String (ConvertStringToDouble(sValue)) to sPEParameterFieldInfo At PEParameterFieldInfo.CurrentValue
       //ConvertStringToDouble ???
       Case Break
    Case (iType = PE_PF_CURRENCY)
       //Put_String (ConvertStringToDouble(sValue)) to sPEParameterFieldInfo At PEParameterFieldInfo.CurrentValue
       //ConvertStringToDouble ???
       Case Break
    Case (iType = PE_PF_BOOLEAN) 
       Put (Integer(sValue)) to sPEParameterFieldInfo At PEParameterFieldInfo.CurrentValue
       Case Break
    Case (iType = PE_PF_DATE)
       // The structure expects a date in 3 byte format similar to a vdf date
       // Put_String (Date(sValue)) fails because it puts "dd/mm/yyyy" into the structure
       // Put (Integer(sValue)) also doesn't work because it only puts the first byte into the structure
       // VDFToCrystal string will convert a VDF date into a 3 byte un-terminated string which will work
       Get VDFToCrystalDate sValue to sBuffer
       Put_String sBuffer to sPEParameterFieldInfo At PEParameterFieldInfo.CurrentValue
       Case Break
    Case (iType = PE_PF_STRING) 
       Put_String (sValue+Character(0)) to sPEParameterFieldInfo At PEParameterFieldInfo.CurrentValue
       Case Break
 Case End
 GetAddress of sPEParameterFieldInfo to pPEParameterFieldInfo
 Move (PESetNthParameterField(iPrintJob,iParameterN,pPEParameterFieldInfo)) to iResult
 Send HandlePossibleError
End_Procedure // Set NthParameterField
 
// VDFToCrystalDate
// Convert VDF Date string to a string representing the same date in crystal
// The return value is meant to be used in Set NthParameterField 
Function VDFToCrystalDate String sValue Returns String
Integer iInteger iValue iLoop iOffset iYear iMonth iResult
Date dValue dMinLimit dMaxLimit
String sBuffer
// Define valid date boundary
Move 693975 to dMinLimit // 1/1/1900
Move 767024 to dMaxLimit // 31/12/2099
// Dates outside dMinLimit & dMaxLimit seem to be unstable, so we enforce a bound
Move sValue to dValue
If (dValue<dMinLimit) Move dMinLimit to dValue
If (dValue>dMaxLimit) Move dMaxLimit to dValue
//Convert VDF date string to an integer value
Move dValue to iValue
// Calculate an offset to adjust for leap-year differences between a VDF date and a Crystal date
// This calculation is only valid between 1/1/1601 and 31/12/2399
Move (DateGetYear(dValue)) to iYear
Move (DateGetMonth(dValue)) to iMonth
Move (iYear-2000) to iYear
If (iYear>0) Begin
   Move (iYear/100) to iOffset
   Move (iOffset-(iYear/400)) to iOffset
End
Else Begin
   Move (iYear/100) to iOffset
   If (iMonth>2 and iOffset) Increment iOffset
End
// 1721044 is the integer difference between a VDF date and a Crystal date representing the same day
// VDF uses a smaller value to represent the same day
// We adjust the VDF date by that number to create a Crystal Date and adjust for leap-years
Move (iValue+1721044-iOffset) to iValue
// Build the 3-byte string that is used by Set NthParameterField
Move (iValue iand $00FF0000) to iResult
Move (iResult/65536) to iResult
Move (Character(iResult)+sBuffer) to sBuffer
Move (iValue iand $0000FF00) to iResult
Move (iResult/256) to iResult
Move (Character(iResult)+sBuffer) to sBuffer
Move (iValue iand $000000FF) to iResult
Move (Character(iResult)+sBuffer) to sBuffer
Function_Return sBuffer
End_Function //VDFToCrystalDate
But, if i put all in a pkg and use it, when i call to the procedure (Set NthParameterField iItem PE_PF_STRING hoReport to svalue) from OnInitializeReport, i recieve the error message 4336 "incapaz de cargar DLL. CRPE32.DLL"
where must i put the code? where and how must i call the procedure NthParameterField?
regards
Iván

Last edited by ivansc; 17-Sep-2009 at 04:02 PM. Reason: it lacked my name
Reply With Quote
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 09:47 AM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright © 2009 Data Access Corporation. All Rights Reserved.