Discussion Locked

Beginner - Crystal Report and VB - Help needed

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hai,
I am using vb6 and crystal report 8.5. I want to pass a parameter to the crystal report from VB. I used the following code from a book I referred. But it shows syntax error. Pl.guide me.

crystalreport1.selectionformula="{servmst.mrtcd}='"&wmrtcd&"'"

wmrtcd is the variable at run time for the parameter.

3 replies

by fbarr_taz

IF WMRTCD IS A VARIABLE, THEN YOU DONT NEED TO PUT IT IN QUOTES OR HAVE & CHARACTERS IN FRONT AND BACK OF IT.

IF THE VARIABLE IS A NUMBER THEN USE
"{XXXX.XXXX} = " & WMRTCD

IF IT IS TEXT USE
"{XXXXXX.XXX} = "'" & WMRTCD & "'"

by meenasrs

The wmrtcd is a string variable. When I tried with the one you post, it shows the following error
Error in formula
'{servmst.mrtcd}='
A number,currency amount,date,time,date-time,boolean or string is expected here.

When I put a ' mark, it automatically changes like a comment.
Pl. help

by sjohnson175

you need to use Chr$().

For example Chr$(34) & strVar & Chr$(34) will pass the contents of strVar with a double-quote on each end.

Get it?

This discussion is closed to new replies.