I have a piece of code to validate that a client doesn't already exist on a table when the user wants to add.
Private Sub ParentGuardianIDX_AfterUpdate()
If DCount("*", "TblGuardian", "[ParentGuardianID] = ParentGuardianIDX") > 0 Then
MsgBox "Guardian already exists on Guardian File!", vbOKOnly
End If
End Sub
My problem is that the message displays then the form 'ends' without the user being able to rectify the problem.
I will want to validate several fields on the form, and the same thing will happen.
I am from a procedural language background where the program would be written to sweep through the input performing necessary validation then only allowing the user to progress once all problems were 'fixed' or the user abandoned the transaction. To achieve this a global 'error' flag would be used.
My question is whether that is the technique advised in VBA code, and if so how does one deploy it?
Private Sub ParentGuardianIDX_AfterUpdate()
If DCount("*", "TblGuardian", "[ParentGuardianID] = ParentGuardianIDX") > 0 Then
MsgBox "Guardian already exists on Guardian File!", vbOKOnly
End If
End Sub
My problem is that the message displays then the form 'ends' without the user being able to rectify the problem.
I will want to validate several fields on the form, and the same thing will happen.
I am from a procedural language background where the program would be written to sweep through the input performing necessary validation then only allowing the user to progress once all problems were 'fixed' or the user abandoned the transaction. To achieve this a global 'error' flag would be used.
My question is whether that is the technique advised in VBA code, and if so how does one deploy it?