Field validation

  • Thread starter Thread starter Katie
  • Start date Start date
K

Katie

Is there a way to make sure a user has entered either a "-"
(dash) or an "L" as part of a field value, i.e. 54283-4 or
8032402 L12?
Thanks,
Katie
 
Why not define it in the table definition with the input
mask. This will carry over to forms and reports.

54283-4 input mask 00000\-0
8032402 L12 input mask 0000000\ \L00

Jim
 
Sorry, I didn't make this clearer...I need to be able to
have both types in one field, called Job. A job can have
either format (a dash or an L), I want to make sure users
enter either a dash or an L.
 
Katie said:
Is there a way to make sure a user has entered either a "-"
(dash) or an "L" as part of a field value, i.e. 54283-4 or
8032402 L12?
Thanks,
Katie

As a validation rule:

Like "*-*" Or Like "*L*"

Or in a control's BeforeUpdate event:

Private Sub txtJob_BeforeUpdate(Cancel As Integer)

If txtJob Like "*-*" _
Or txtJob Like "*L*" _
Then
' entry is okay
Else
Cancel = True
MsgBox "Invalid job number!"
End If

End Sub
 
Thanks...the validation rule works great!

Katie
-----Original Message-----


As a validation rule:

Like "*-*" Or Like "*L*"

Or in a control's BeforeUpdate event:

Private Sub txtJob_BeforeUpdate(Cancel As Integer)

If txtJob Like "*-*" _
Or txtJob Like "*L*" _
Then
' entry is okay
Else
Cancel = True
MsgBox "Invalid job number!"
End If

End Sub

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.
 
Back
Top