Trying to select tables based on user input but it won't work

75 Views Asked by At

I'm new to crystal reports I'm trying to change the selected tables based on user input in SAP crystal reports but when I enter a value it shows an error message, this is the code :

if({?Type}='Commande client') begin select rdr1.docentry,rdr1.itemCode, rdr1.dscription, rdr1.quantity,rdr1.price,rdr1.currency,rdr1.slpCode,rdr1.basedocnum,
rdr1.shiptocode,rdr1.shiptodesc,rdr1.baseprice,rdr1.itemtype,ordr.docnum,ordr.doctype,ordr.docstatus,ordr.docTotal,ordr.docdate,
ordr.cardcode,ordr.cardname,ordr.address,ordr.doccur,ordr.paidtodate,ordr.doctime,ordr.docsubtype,ordr.basetype,
ordr.baseEntry from ordr inner join rdr1 on ordr.docentry=rdr1.docentry end

if({?Type}='Offre/Devis client') begin select qut1.docentry,qut1.itemCode, qut1.dscription, qut1.quantity,qut1.price,qut1.currency,
qut1.slpCode,qut1.basedocnum,qut1.shiptocode,qut1.shiptodesc,qut1.baseprice,qut1.itemtype,oqut.docnum,oqut.doctype,oqut.docstatus,
oqut.docTotal,oqut.docdate,oqut.cardcode,oqut.cardname,oqut.address,oqut.doccur,oqut.paidtodate,oqut.doctime,oqut.docsubtype,
oqut.basetype, oqut.baseEntry from oqut inner join qut1 on oqut.docentry=qut1.docentry end

if({?Type}='Livraison client') begin select dln1.docentry,dln1.itemCode, dln1.dscription, dln1.quantity,dln1.price,dln1.currency,
dln1.slpCode,dln1.basedocnum,dln1.shiptocode,dln1.shiptodesc,dln1.baseprice,dln1.itemtype,odln.docnum,odln.doctype,odln.docstatus,
odln.docTotal,odln.docdate,odln.cardcode,odln.cardname,odln.address,odln.doccur,odln.paidtodate,odln.doctime,odln.docsubtype,
odln.basetype, odln.baseEntry from odln inner join dln1 on odln.docentry=dln1.docentry end
```[text is in French but it basically translates to: impossible to extract data from data base
Native error: 102 [supplier code of the database: 102 ][1]
could anyone tell where the problem is.


  [1]: https://i.stack.imgur.com/Pro8O.png
1

There are 1 best solutions below

0
On BEST ANSWER

Found a way to fix it, it just needed quotes:

declare @type nvarchar(30)

set @type= '{?Type}'