>>I have designed "Report preview.scx" in that i have placed two text boxes namely 1.txtfromdate 2.txtdateto and one command >>button namely
>>"cmdpreviw". I want to preview data between two dates and I have written code below
>>local lcFrom, lcTo
>>lcFrom = ThisForm.TxtFromdate.Value
>>lcTo = ThisForm.TxtTdateto.Value
>>select * from student;
>>where date between CTOD(lcFrom )and CTOD(lcTo);
>>order by date;
>>into cursor Temp
>>Report form "D:\List.frx" preview
>>For first time I have entered dates in corresponding text boxes and click command button the preview will display, and i have clear >>the dates in two text boxes again I have entered different dates and click command button the preview will not display.
>>how to correct my code? or
>>Kindly advise me how to write code?
>>thanking you
You have not mentioned exactly what the problem/error is, but I am guessing that your code may be crashing because you are trying to create a 2nd cursor with the same name? You also need to ensure you are at the top of the cursor before calling the report (use LOCATE)
I would write like this;
IF USED("temp")
SELECT temp
ELSE
SELECT 0
ENDIF
SELECT * FROM student;
WHERE BETWEEN(date,THISFORM.txtFromDate.Value),THISFORM.txtDateTo.Value) ) ;
ORDER BY date;
INTO CURSOR temp
LOCATE
REPORT FORM "d:\list.frx" PREVIEW
There is also no need to store your values to lcFrom and lcTo, you can just reference the textboxes.
Gary.