Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help Passing Variables to UFL

Status
Not open for further replies.

CarlLB

Programmer
Apr 1, 2003
3
SA
I'm a VB developer who is new to Crystal Reports and the RDC. I've created a UFL which contains a number of functions used by both my VB code and by the RDC's formulas. I need to pass a value from VB to the UFL, process the code based on the passed in value and return the results. I created a public property let in the DLL to receive the value and store it as a modular level variable. The trouble is that this variable is not being remembered the next time it's referenced from the same report. Any help would be greatly appreciated.
 
I forgot to mention I'm using VB6 and Crystal version 9 - thanks
 
If you want to maintaint the value in the variable in the UFL, declare a variable at a global level in VB.

This is all VB code inside the UFL....

Option Explicit
Dim MyVar as string

Public Function SaveMyVar(Save as string) as string
myVar=Save
SaveMy="string saved"
End Function

Public Function GetMyVar() as string
getMyVar = Save
End Function

The other thing to watch in CR, is that the UFL functions might need to be done WhilePrintingRecords to make them work.
Editor and Publisher of Crystal Clear
 
Thanks for the quick response. Your suggestion is what I tried first and I couldn't get it to work. I did not try using WhilePrintingRecords and will do that.

To further clarify what I'm trying to accomplish. My VB app has 15 different reports. Before each one is run I am passing the report name (ie "Status") to the UFL so that when the report's formulas need to call a UFL function that is shared by other reports (for a decode value etc), the global variable is used in an if else statement to route the code where it needs to go. This is where it's not remembering the global variable.

I've tried creating a global instance of the UFL in my app but the formulas in the reports don't recognize them.

I read last night about Shared variables between sub reports and reports (don't forget I'm new to CR) and that looks promising because the formulas supposedly will recognize these variables, then I can modify my UFL functions to look for an optional variable which would be the shared variable.

I'd appreciate any better ideas.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top