Results 1 to 4 of 4

Thread: [RESOLVED] Error validation issue.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2006
    Posts
    449

    Resolved [RESOLVED] Error validation issue.

    Hello All,

    I have an "Inputerror" validation for when the user clicks on the "Save or Update" buttons.

    This is the code:
    vb Code:
    1. Private Function InputError()
    2.  
    3. InputError = True
    4.  
    5.  
    6.    
    7. 'checks to make sure the user inputs only numbers in the zip code
    8. If txtZip.Text <> "" Then
    9.     If Not IsNumeric(txtZip.Text) Then
    10.         Call MsgBox("Zip Code must be numerals only!", vbInformation + vbOKOnly, "Zip Code")
    11.         txtZip.Text = ""
    12.         txtZip.SetFocus
    13.         Exit Function
    14.     End If
    15. End If
    16.  
    17. 'Checks to make sure the user entered a FDID and in the correct format
    18. If txtFDID.Text = "" Or txtFDID.Text <> "" Then
    19.     Dim r As RegExp
    20.     Dim m As String
    21.     Set r = New RegExp
    22.    
    23.    
    24.     r.Pattern = "^[A-Z][0-9][0-9][0-9]$"
    25.     r.IgnoreCase = True
    26.    
    27.     m = r.Test(txtFDID.Text)
    28.    
    29.     If m = False Then
    30.         MsgBox "The information that you have entered for the FDID field is not valid or you forgot to make an entry:" & vbCrLf & "1. The FDID is REQUIRED!" & vbCrLf & "2. The FDID must be in the A123 format!" & vbCrLf & "For example: First entry must be a letter (A-Z) followed by" _
    31.         & " three numbers (0-9)!", vbOKOnly, "Note"
    32.         txtFDID.Text = ""
    33.         txtFDID.SetFocus
    34.     End If
    35.     Exit Function
    36. End If
    37.  
    38. InputError = False
    39. End Function

    Well the problem is this:

    When the user clicks on the Save or Update button and they input the incorrect data, then it goes to the "Inputerror" function.

    This works fine, but when I go back and correct the info then click on the Save or Update button - nothing happens!

    This is the code for the Save button:

    vb Code:
    1. Case "Save"
    2.             If InputError() Then Exit Sub
    3.             With rs
    4.                 If booIsAdding Then .AddNew
    5.                 .Fields("fldFname").Value = txtFname.Text
    6.                 .Fields("fldMI").Value = txtMI.Text
    7.                 .Fields("fldLname").Value = txtLname.Text
    8.                 .Fields("fldFDID").Value = txtFDID.Text
    9.                 .Fields("fldDOB").Value = DTPicker
    10.                 .Fields("fldAddress").Value = txtAddress.Text
    11.                 .Fields("fldCity").Value = txtCity.Text
    12.                 .Fields("fldState").Value = txtState.Text
    13.                 .Fields("fldZip").Value = txtZip.Text
    14.                 .Fields("fldSname").Value = txtSname.Text
    15.                 .Fields("fldChildren1").Value = txtChildren1.Text
    16.                 .Fields("fldDob1").Value = DTPicker1
    17.                 .Fields("fldChild2").Value = txtChild2.Text
    18.                 .Fields("fldDob2").Value = DTPicker2
    19.                 .Fields("fldChild3").Value = txtChild3.Text
    20.                 .Fields("fldDob3").Value = DTPicker3
    21.                 .Fields("fldChild4").Value = txtChild4.Text
    22.                 .Fields("fldDob4").Value = DTPicker4
    23.                 .Fields("fldChild5").Value = txtChild5.Text
    24.                 .Fields("fldDob5").Value = DTPicker5
    25.                 .Fields("fldChild6").Value = txtChild6.Text
    26.                 .Fields("fldDob6").Value = DTPicker6
    27.                 .Fields("fldChild7").Value = txtChild7.Text
    28.                 .Fields("fldDob7").Value = DTPicker7
    29.                 .Fields("fldContact1").Value = txtContact1.Text
    30.                 .Fields("fldRelationship1").Value = txtRelationship1.Text
    31.                 .Fields("fldAddress1").Value = txtAddress1.Text
    32.                 .Fields("fldPhone1").Value = txtPhone1.Text
    33.                 .Fields("fldCell1").Value = txtCell1.Text
    34.                 .Fields("fldOther1").Value = txtOther1.Text
    35.                 .Fields("fldContact2").Value = txtContact2.Text
    36.                 .Fields("fldRelationship2").Value = txtRelationship2.Text
    37.                 .Fields("fldAddress2").Value = txtAddress2.Text
    38.                 .Fields("fldPhone2").Value = txtPhone2.Text
    39.                 .Fields("fldCell2").Value = txtCell2.Text
    40.                 .Fields("fldOther2").Value = txtOther2.Text
    41.                 .Fields("fldContact3").Value = txtContact3.Text
    42.                 .Fields("fldRelationship3").Value = txtRelationship3.Text
    43.                 .Fields("fldAddress3").Value = txtAddress3.Text
    44.                 .Fields("fldPhone3").Value = txtPhone3.Text
    45.                 .Fields("fldCell3").Value = txtCell3.Text
    46.                 .Fields("fldOther3").Value = txtOther3.Text
    47.                 .Fields("fldPrimary").Value = txtPrimary.Text
    48.                 .Fields("fldFdid1").Value = txtFdid1.Text
    49.                 .Fields("fldSecondary").Value = txtSecondary.Text
    50.                 .Fields("fldFdid2").Value = txtFdid2.Text
    51.                 .Fields("fldReligious").Value = txtReligious.Text
    52.                 .Fields("fldSrequest").Value = txtSrequest.Text
    53.                 .Fields("fldComments").Value = txtComments.Text
    54.                 .Update
    55.             End With

    What am I doing wrong?

  2. #2
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968

    Re: Error validation issue.

    Try putting a breakpoint on this line and see what the value is.
    Code:
    If InputError() Then Exit Sub
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2006
    Posts
    449

    Re: Error validation issue.

    LOL, I found the mistake!

    I had the "exit function" in the wrong place.

    vb Code:
    1. 'Checks to make sure the user entered a FDID and in the correct format
    2. If txtFDID.Text = "" Or txtFDID.Text <> "" Then
    3.     Dim r As RegExp
    4.     Dim m As String
    5.     Set r = New RegExp
    6.    
    7.    
    8.     r.Pattern = "^[A-Z][0-9][0-9][0-9]$"
    9.     r.IgnoreCase = True
    10.    
    11.     m = r.Test(txtFDID.Text)
    12.    
    13.     If m = False Then
    14.         MsgBox "The information that you have entered for the FDID field is not valid or you forgot to make an entry:" & vbCrLf & "1. The FDID is REQUIRED!" & vbCrLf & "2. The FDID must be in the A123 format!" & vbCrLf & "For example: First entry must be a letter (A-Z) followed by" _
    15.         & " three numbers (0-9)!", vbOKOnly, "Note"
    16.         txtFDID.Text = ""
    17.         txtFDID.SetFocus
    18.         Exit Function <---to here
    19.     End If
    20.     Exit function <--moved this from here
    21. End If

    Thanks anyway!
    Last edited by cfd33; Nov 19th, 2007 at 11:47 AM.

  4. #4
    Frenzied Member aikidokid's Avatar
    Join Date
    Aug 2002
    Location
    Bristol, UK
    Posts
    1,968

    Re: Error validation issue.

    Quote Originally Posted by cfd33
    LOL, I found the mistake!

    I had the "exit function" in the wrong place.
    Glad you got it sorted.
    If somebody helps you, take time to RATE the post. I do.

    "FAILURE IS NOT AN OPTION. It comes bundled with the software."

    Below are some of the threads that have helped me along the way:

    CodeBank submission:
    Listview Backcolor (without subclassing)

    Loading Treeview Nodes From A Database, Creating Registry Keys, Count Number of Lines in TextBox , Excellent RichTextBox Tricks & Tips
    Ideas & Screen Shots For A Code Library App
    How to do Data validation in Excel, Conditional Formating in Excel

Posting Permissions

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



Click Here to Expand Forum to Full Width