Form level validation

VPK_Access

Registered User.
Local time
Tomorrow, 01:55
Joined
May 15, 2011
Messages
36
Hi,

Currently in my access system, I have used validation on Table level for fields which needs to be entered mandatory.(Required=Yes).

However when the user enters the data, the validation pops up after every field(if data is missed). How can I prompt the user for all validation only as the user exists/before saving the set of data.

Can I know which event should I use on the Form level, that will prompt the user ...before going to the next of record.
 
Use the Form's Before Update Event
 
* already answered
 
When I gave the validation in the Before upadte event of the form, the validation works.....however the validation message pops up even when the user clciks on the field.

For eg: If there is a validation for field A, B , C....after the user enters the value for A, when he clicks on B, the Validation message shows up. How can I prevent this?
 
I handle multiple validations in a different way (not to say that its the correct way)

I create a button and in the on click event place code like below, which checks that required fields are not null and a lookup that checks to see if the "Employee Number" already exists and then provides a message etc. It uses the IF, ELSE and EVAL functions.

Code:
Private Sub Command62_Click()
On Error GoTo Err_Command62_Click


    
If (Eval("[Forms]![Frm_NewEmp]![Name] Is Null")) Or (Eval("[Forms]![Frm_NewEmp]![Surname] Is Null")) Or (Eval("[Forms]![Frm_NewEmp]![EmpNumber] Is Null")) Then
        Beep
        MsgBox "Both NAME, SURNAME and EMPNUMBER are required!", vbOKOnly, ""
    Else
    
        If Not IsNull(DLookup("EmpNumber", "Tbl_Employees", "EmpNumber=" & EmpNumber)) Then
        MsgBox ("EmpNumber already exists.")
        Cancel = 1
        EmpNumber.SetFocus
    Else
        MsgBox ("New Employee Added.")
        
    DoCmd.Close
    End If

    

Exit_Command62_Click:
    Exit Sub

Err_Command62_Click:
    MsgBox Err.Description
    Resume Exit_Command62_Click
    
End If


End Sub
Private Sub Command63_Click()
On Error GoTo Err_Command63_Click


    DoCmd.GoToRecord , , acLast

Exit_Command63_Click:
    Exit Sub

Err_Command63_Click:
    MsgBox Err.Description
    Resume Exit_Command63_Click
    
End Sub
 

Users who are viewing this thread

Back
Top Bottom