Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Date Filter on Form doesn't work properly
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01461572
Message ID:
01461604
Views:
72
Is it possible to avoid using filter?
If not, you need to do it like this
lcFilter = [Quotes.dQuote >= {] + transform(dFrom,'^9999-99-99') + [} and Quotes.dQuote <={] + transform(dThru,'^9999-99-99') + '}'

set filter to &lcFilter
locate
&& Better to use locate than GO TOP

>Oops! Yeah, it was returning an empty date. Even after cleaning this up and buiilding the compelte dates, I am now getting another error when I hit the COMMAND, "SKIP", which is the result of my hitting a navigational button called NEXT. The error says, "dThru not found". dThru is one of the variables used in the date range of the filter. Ugh! What is going on with this? Why does SKIP produce an error?
>
>
>WITH ThisForm
>	IF .IsChanged()
>		.SaveIt()
>	ENDIF
>	IF EOF()
>		GO BOTTOM
>		.bottomButton.Enabled = .F.
>		.nextButton.Enabled = .F.
>	ELSE
>		SKIP
>		IF BOF()
>...more code
>
>
>New SetDateFilter Method's code:
>
>WITH ThisForm
>	IF NOT EMPTY(.txtDateFrom.Value) AND ;
>			NOT EMPTY(.txtDateThru.Value)
>		* Build the From Date.
>		cFrom      = .txtDateFrom.Value
>		cFromMonth = LEFT(cFrom, 2)
>		cFromDate  = SUBSTR(cFrom, 3, 2)
>		cFromYear  = RIGHT(cFrom, 4)
>		dFrom      = CTOD(cFromMonth + "/" + cFromDate + "/" + cFromYear)
>		SET STEP ON
>		* Build the Thru Date.
>		cThru      = .txtDateThru.Value
>		cThruMonth = LEFT(cThru, 2)
>		cThruDate  = SUBSTR(cThru, 3, 2)
>		cThruYear  = RIGHT(cThru, 4)
>		dThru      = CTOD(cThruMonth + "/" + cThruDate + "/" + cThruYear)
>		SELECT Quotes
>		SET FILTER TO BETWEEN(Quotes.dQuote, dFrom, dThru)
>		GO TOP
>		.Refresh()
>	ENDIF
>ENDWITH
>
>>Did you check values in dFrom and dThru? CTOD() will return empty date if it cannot convert the parameter passed to a date.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform