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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can clear the value in a textbox where i input date

Status
Not open for further replies.

titoneon

MIS
Dec 11, 2009
335
US
Hi,
I have a textbox where i input a date and i have this named as txtdate, so the txtdate Dateformat property = 1
So i would like to use the DblClick property to clear the value i typed in the Txtdate, so i wrote inside the property the following
Code:
This.Value = ''
this.txtdate.DateFormat = 1  && i put this line here to get the " / /    " on the txtdate back,  after it got cleared but this does not work for me
** what should i do to make the txtdate to get the format as before ?

after i double click on the txtdate, the previous date, got cleared from the txtbox but i got this error "unknown member value"
can you guide me here to get this right ?
Thanks
 
I think your problem is that your code is setting the texbox to a character value, when it is presumably bound to a date field. The culprit is this line:
[tt]
This.Value = ''[/tt]

If you want to initialise it to an empty date, you need something like this:

[tt]This.Value = {}[/tt]

Give it a try and report back.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Yes Mike , that is working as i was expecting, now let me ask you.
if want to put in the doubleclick event soemthing like this

this.txtdate.dateformat = 1
should that do the same thing as This.Value = {} ?
Thanks
 
The dateformat property will set the display of dates. But the .value still and even more so has to be a date, not an empty string. '' is empty string literal, {} is an empty date literal.

Bye, Olaf.
 
Hi,

Also, make the
Code:
this.txtdate.dateformat = 1
to
Code:
this.dateformat = 1
because "this" already refers to the object "txtdate".

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
As Kilroy says, the Dateformat property belongs to the textbox. If your code is located in the textbox's DblClick, then "this" refers to the textbox, so you don't need "txtdate". In other words, do this:

[tt]this.dateformat = 1[/tt]

But I'm not clear why you need to do this - for two reasons. First, you can simply use SET DATE at the start of your program to establish the desired date format. You would only normally use Dateformat if a specific textbox has a different date format, which would be very unusual.

But even if you do need to set Dateformat, why not do it once only, at design time or in the control's Init? You don't have to constantly do it each time the user wants to clear the textbox.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top