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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass string to CR8.5 Report

Status
Not open for further replies.

MartinDurant

Programmer
Jan 25, 2002
41
GB
I am using VB6 and CR8.5. I have a report which is an event register - a list of names and a tick box to allow attendance to be recorded. The list of names is coming from my database, but I need to put the event name at the top of the report. The event name is being selected by the user from a drop-down list. I am trying to pass this string value as a parameter, and get an "Enter Parameter Values" dialog box displayed with my string in it. I select OK and my report is fine. How do I stop this dialog box being displayed and get the value straight to my report?

Here is my parameter code (strSelectedEvent is the event name string):

Code:
    crpEventRegister.ParameterFields(1).AddDefaultValue strSelectedEvent

Any help is greatly appreciated.

Martin Durant
 
You have to tell the report you don't want to see the prompt. Try this statement just before sending the report to the viewer:
[tt]
crpEventRegister.EnableParameterPrompting = False
[/tt]
-dave
 
Dave
I gave is a go, and it stopped the the prompt. It also stopped the parameter being passed too.

To my mind this is a fairly simple objective and I can't see why it's so difficult. I can pass shed loads of data from a database, but I can't pass a simple text field.

Thanks anyway,

Martin
 
Try:

crpEventRegister.ParameterFields(1).AddCurrentValue strSelectedEvent

-dave
 
Dave

Gave this a go. With the prompt switched off, the parameter doesn't get passed. With the prompt on, the Enter Parameter Values dialog box is displayed, but with nothing in the Discrete Value field. Either way, still no passed parameter in my report.

Martin
 
Martin,

Are you willing to try a different approach?

Create a formula field on the report called SelectedEvent with nothing as it's text. Drag the formula to the top of your report, and format it however you like.

In VB, before previewing or printing the report, set the formula like this:
[tt]
crpEventRegister.FormulaFields.GetItemByName("SelectedEvent").Text = Chr(34) & strSelected & Chr(34)
[/tt]
The Chr(34)'s are there to pad the string with double quotes.

-dave
 
Dave,
I am happy to try any way that works! I have made the changes above and now get an 'Invalid name' error on this line.

crpEventRegister.FormulaFields.GetItemByName("SelectedEvent").Text = Chr(34) & strSelected & Chr(34)

I have checked all the spelling in both VB and CR.
Martin
PS Your help is much appreciated.
 
Martin,

You can loop through the FormulaFields collection to verify you've got the correct name:
[tt]
Dim cFormula As CRAXDRT.FormulaFieldDefinition
For Each cFormula In crpEventRegister.FormulaFields
Debug.Print cFormula.FormulaFieldName
Next
[/tt]
Or, you can loop through to see the index of each formula:
[tt]
For i = 1 To crpEventRegister.FormulaFields.Count
Debug.Print crpEventRegister.FormulaFields(i).FormulaFieldName & " - Index = " & Str(i)
Next i
[/tt]
With the second method, once you see what the index of the SelectedEvent formula is, you can set the text like:
[tt]
crpEventRegister.FormulaFields(1).Text = Chr(34) & _
strSelected & Chr(34)
[/tt]
Hope this works, it really shouldn't be this much trouble.

-dave
 
That's the badger! Thanks very much - it's quite straight forward when you know how. I don't understand why my text field counts as a formula rather than a parameter.

Thanks again.

Martin.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top