Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compare two textboxes

Status
Not open for further replies.

R17

Programmer
Jan 20, 2003
267
PH

i have textbox txtfrdate and txttodate. i'd like to give a message whenever txttodate is less than txtfrdate.

how do i do that?
 
In case of character input:
you can do it this way:
if len(alltrim(thisform.txtfrdate.value))<len(alltrim(thisform.txtdate.value))
messagebox(....)
endif

Put this code in lost focus property of yours textboxes


In case of date input
if thisform.txtfrdate.value<thisform.txtdate.value
messagebox(....)
endif
 
Hi

The user can enter txtfrdate and txttodate
The user can enter txtfrdate only
The user can enter txttodate only
The user need not enter on both..

So the way to go is..

In the Forms Init event..
ThisForm.txtfrdate.Value = DATE()
ThisForm.txttodate.Value = DATE()

In the LostFocus of
ThisForm.txtfrdate
IF ThisForm.txtfrdate.Value > ThisForm.txttodate.Value
ThisForm.txttodate.Value = ThisForm.txtfrdate.Value
ENDIF

In the LostFocus of
ThisForm.txttodate
IF ThisForm.txttodate.Value < ThisForm.txtfrdate.Value
** either
ThisForm.txttodate.Value = ThisForm.txtfrdate.Value
NODEFAUT
** OR
=MESSAGEBOX(&quot;UnAcceptable Date value&quot;,0+16)
NODEFAULT
ENDIF


You can also force validation and set focus back, just before you start your report or before data update.

:)

____________________________________________
Ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top