Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264

    Unanswered: Data validation - Before Update

    I am trying to do a data validation test before a field is updated. I have added a beforeUpdate procedure which does the test that I want. Problem is, I can't keep the focus on the control in question. I want to keep them there until they either enter something valid or clear the field.

    I tried doing a setfocus in the before update and got the warning that I have to save the field before I can set focus to it.

    How should I be doing my validation to achieve the desired result?

    Thanks!

    Steve

  2. #2
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    What you might try is if the field is invalid set it to "" then set the focus on it and produce a message box that lets them know to either leave it blank as it is now, or to enter a valid item.

    Something along those lines help?

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  3. #3
    Join Date
    Aug 2004
    Posts
    13

    Lightbulb

    try setting the trigger on AfterUpdate then running an IF statement to validate the data.
    If the data is valid... Exit Sub
    If Not Valid, MsgBox "Invalid", setfocus on appropriate field - End IF

    I use this type of validation a lot

  4. #4
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264
    Well, it isn't working as I would like it to. This is what I have currently

    Code:
     
    Private Sub InvoiceNum_AfterUpdate()
    	If duplicateInvoiceNum = True Then
    		MsgBox "Invoice " & InvoiceNum.Value & " is a duplicate", _
    			48, "Duplicate"
    		InvoiceNum.SetFocus
    	End If
    End Sub
    Where duplicateInvoiceNum is a function returning true or false

    The validation works fine but the focus does not stay in that field. I have tried the same code in several different event triggers all with the same result.

    How can I keep them in that field until they enter valid data?

    Thanks again!

    Steve

  5. #5
    Join Date
    Aug 2004
    Location
    Cary, NC
    Posts
    264

    Solved It

    Problem was solved.

    See post by MikeTheBike in "Check for Duplicates on 4 fields" thread


    thanks for all the help.

    Steve

Posting Permissions

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