ChatterBank6 mins ago
Microsoft Access 2000
8 Answers
If I have a text field in a table is it possible to have a validation rule to ensure the field contains no spaces?
Answers
Best Answer
No best answer has yet been selected by NickleArse. Once a best answer has been selected, it will be shown here.
For more on marking an answer as the "Best Answer", please visit our FAQ.It is simpler to do this in VBA
Paste this code into the BeforeUpdate Event code window...
If IsNull(txtReg) Then
Exit Sub
End If
If InStr(1, txtReg, " ") > 0 Then
MsgBox "Please do not include spaces ", vbOKOnly, "Invalid Reg Number"
Cancel = True
End If
Adjust txtReg to be whatever you named that field and that should do the trick for you
Paste this code into the BeforeUpdate Event code window...
If IsNull(txtReg) Then
Exit Sub
End If
If InStr(1, txtReg, " ") > 0 Then
MsgBox "Please do not include spaces ", vbOKOnly, "Invalid Reg Number"
Cancel = True
End If
Adjust txtReg to be whatever you named that field and that should do the trick for you