Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2002
    Posts
    10

    Question Unanswered: 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?

  2. #2
    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 ?

  3. #3
    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

  4. #4
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •