Im guessing you have the user type the key? If so, you can add code to the control's
BeforeUpdate. Asumming your textbox is called: tb_Primary you do like this.
Select your
textbox, open the
properties window, then the
events tab. Find the
BeforeUpdate, and click the 3 ... on the right hand side of the window, and select
Event Procedure. You will now be taken to the VBA editor looking like this:
- Private Sub tb_Primary_BeforeUpdate(Cancel As Integer)
-
-
End Sub
Modify it to look like this, and you should be good to go:
- Private Sub tb_Primary_BeforeUpdate(Cancel As Integer)
-
If len(Me.tb_Primary)<>5 then
-
'Input error
-
Msgbox "Primary Key must be 5 charecters long, please correct"
-
'Cancel the update of the field
-
Cancel=true
-
End If
-
End Sub