If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Field Validation of a Date format

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-26-02, 12:44
aotc2002 aotc2002 is offline
Registered User
 
Join Date: Aug 2002
Posts: 10
Question Field Validation of a Date format

Field Validation of a Date format

The way my application is written is that I press an enter data button that uses (Adodc1.Recordset.AddNew) which clears my fields and adds a record, then I'm allowed to enter data. To verify that the data has in fact been entered i use the navigation buttons to cycle thru the recordset. However, i get a runtime error when the date is input properly.

For example: format = dd/mm/yy, example: 26/08/02 v.s. an improper input date data such as 31/31/02 which triggers the error.

How can i catch this given that the record has been already added before the data is actually input?

Ive tried setting an error handler on the navigation buttons but it doesnt work correctly, what kind of code would i need to validate the date for this text box?
Reply With Quote
  #2 (permalink)  
Old 08-26-02, 22:05
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
What is the error you are receiving ? When are you receiving the error ? When do you do adodc1.recordset.update ?
Reply With Quote
  #3 (permalink)  
Old 08-27-02, 06:46
aotc2002 aotc2002 is offline
Registered User
 
Join Date: Aug 2002
Posts: 10
Lightbulb solution

It was a
Run time error: '-2147217842 (80040e4e)'

I solved the date validation issue with this:

If Not IsDate(MaskEdBox1.Text) Then
MsgBox "Invalid Date! Please enter a valid date (dd/mm/yy)!", vbOKOnly, "Invalid Date!"
MaskEdBox1.SetFocus '<== Returns cursor to the MaskEdBox1 field
End If

thx for youre help
Reply With Quote
  #4 (permalink)  
Old 08-28-02, 23:23
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
I was confused when you said "However, i get a runtime error when the date is input properly". Anyway, when you post, including the error message and being as descriptive as possible (like the masked edit control) is helpful. You can also include your code in a lostfocus event for the date field so that the user will have to choose a correct date. You can also validate as the user is entering the date to prevent user input error as well - this is a little more code intensive than just running isdate.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On