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

How do I pass a string parameter to Crystal from a VB text box?

Crystal and VB

How do I pass a string parameter to Crystal from a VB text box?

by  mdctsg  Posted    (Edited  )
If you are familar with Crystal Reports then skip to Part 2

Part 1

Create your report in Crystal. Insert your parameter. If you are not familar with it go to Insert, select Field Object. Then select Parameter Fields. Next select the new button (Which looks like a page with a yellow star). Give your parameter a name and make sure the value type is String. Then select OK. Then drag the parameter into your report and select close. Next, right click on the parameter and choose Select Expert. If this is your only parameter select the field your parameter will represent. Then select OK. Next in the combo drop down menu select "is equal to". The in the other combo box that appears select your parameter, then ok. That will prompt you for the parameter the next time you refresh

Part 2

On your form place the Crystal Reports Control, a Text Box and a Command Button
Name the Report Control to CR1 or whatever you want.

The same for the textbox.
In your Command Button Code

Code:
Private Sub Command1_Click()

With CR1
 .ReportFileName = App.Path & "\Your Report.rpt
 .ParameterFields(0) = "Your Crystal Parameter Name;" & Your Text Box Name & ";TRUE;"
 .Destination = crptToWindow
 .Action = 1
 .PageZoom (100)

End With
End Sub

Adding the TRUE to the statement stops the Crystal prompt from appearing allowing you to use your text box as the parameter.
I made the mistake of declaring the textbox do don't do that. Don't put the ? that is attached to your parameter in crystal

I hope this will help someone with the same problem. I have seen this question many times.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top