If statement to compare

D

dustinl15

I need to make an If statement that will compare a UserName on a form to a
UserName in a SecurityTable to make sure one does not already exist. And if
there is one already in the Table the Form will show a message that says it
is already in the table. Here is what I have and it is giving me an error.
Could you help me out and let me know what I am doing wrong.

If (Me.UserNameTxtBx <> Tables!SecurityTable!UserName) Then
MsgBox ("User Name already exists")
End If
 
D

Duane Hookom

Try:

If DCount("*","SecurityTable","UserName='" &Me.UserNameTxtBx & "'" ) >0
Then
MsgBox ("User Name already exists")
End If
 
Top