Click to See Complete Forum and Search --> : how to give selection formula


query4u
July 12th, 2006, 05:39 AM
hi,
i have designed one report. i want to display records ,for that i will specify the range like prodno between 1 to 100 then it will print the record from 1 to 100. if i specify 10 to 20 then it will print 10 to 20.
in selection formula i have written following code

with cr1
.Connect = strr1
form1 = "{product_tab.prod_id}>" & txtfrom & " and {product_tab.prod_id}<=" & txtto

.SQLQuery = "select * from product_tab"
.SelectionFormula = form1
.WindowShowPrintBtn = True
.WindowState = crptMaximized
.Action = 1
end with
in txtfrom i m specifying lower limit & txtto upper limit.
but it is not displaying records. can anyone tell me what i ve to write in seletion formula.

wapper
July 13th, 2006, 09:29 AM
Are you using the Crystal OCX control to display the report?
It is bad practice to override .SQLQuery, because it is already contained in the RPT file. Just set the .SelectionFormula to limit the rows returned by the query in the report.
SQLQuery should only be altered if there is no other way to achieve what you want, for example, if you want to replace some tables in your report. I haven't used OCX for ages, but IIRC if you change the SQLQuery, the SelectionFormula no longer works, as it is overridden by the SQLQuery.