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!

Error Message Invalid Date

Status
Not open for further replies.

Fathir2007

Programmer
Dec 24, 2019
1
ID
Please help the experts,

I use VF.9 and try the following code:
vardate = ctod (" - - ")
@ row, col get vardate
read

When incorrectly entering the vardate, there is an error message Invalid Date (press space) below the screen position. The error message is different if I use VFP.6 where error message in an dialog box which looks better and standard
Please advise if the "error message" in VFP 9 is a bug? If it's a bug, how do I customize it.

Thank you.
 
Why should you initiate the variable by ctod() ?

Just declaring vardate = {} will be enough.

And the error message you said looks odd. Was that the exact error message? Or was it Date/datetime evaluated to an invalid value ? (This too displays a dialog box.)

By your question, I guess that it should be a text field which later converts into a date field, and the error message is shown in the status bar through the 'message' clause or 'error' clause of @... get command.
 
No, of course it's not a bug. You enter an invalid date. You get a message saying that it is an invalid date. How can that be a bug?

You ask how you customise the message. You set up your own error-handler, which traps the relevant error, after which you can take whatever action you wish.

But a far better approach would be to ditch @ .. GET and READ completely, and do the whole thing with a VFP form. Judging by the wording of your question, you appear to have moved from VFP 6.0 to 9.0, which suggests you have been using the product for some time, which further suggests that you should have had time to learn how to use Visual Foxpro rather than trying to maintain your old code.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Yes, Mike is correct "Invalid Date" message is not a bug. It is an error message from Foxpro when user enters incorrect date.

As you are using "@ row, col get " commands for accepting values from user, You can use VALID clause along with "@ row, col" to customize/Handle error message. But if the variable "VARDATE" is of DATE datatype then "Invalid Date" message will come when user enters wrong date.


Mukesh Khandelwal
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top