Extra validation

pipmic

New member
Local time
Tomorrow, 00:14
Joined
Feb 13, 2015
Messages
7
Hi,
I am trying to add extra validation in a sample db (done in A97 (converted to A2003)see attached.

I am attempting the following: Please not that the db has existing validation which I would like to keep (or change if advised) 

Conditions:
1. Input into field “ID” must start with the letter P or p or R or r
2. If field “ID” starts with the letter P or p and field “Code” starts with the letter R or r, then a message stating that this combination is invalid should appear
3. If field “ID” starts with the letter R or r and field “Code”] starts with the letter P or p, then a message stating that this combination is invalid should appear


Grateful for assistance. Thanks
 

Attachments

You seem to article it well. Isn't code for this nested if statements?
 
Was hoping if someone could get me started off with the coding!
 
I have the following: but I get a compile error

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.PV_Number & "" = "" Then
MsgBox "You must make an entry in the ID field!"
Me.PV_Number.SetFocus
Cancel = True
ElseIf Not (Me.PV_Number Like "[PpRr]*") Then
MsgBox "ID must begin with 'P', 'p', 'R', or 'r'!"
Me.PV_Number.SetFocus
Cancel = True
ElseIf (Me.PV_Number Like "[Pp]*") And (Me.Code Like "[Rr]*") Then
MsgBox "IF PV Number begins with 'P' or 'p' then the 'Code' field cannot begin with an 'R'!"
Me.Case.SetFocus
Cancel = True
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom