creating a message box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am in the process of creating a database, in the database I want to create
a message box that would prevent duplicate account numbers. When a user
enters in a client's account number and if it is a duplicate number a message
box should appear after the user selects the enter key or before they
continue on to the next text box.

I have been have trouble with this for to long. So if someone could provide
me with some insight, that would be helpful.

Thanks
 
Sheria said:
I am in the process of creating a database, in the database I want to
create a message box that would prevent duplicate account numbers.
When a user enters in a client's account number and if it is a
duplicate number a message box should appear after the user selects
the enter key or before they continue on to the next text box.

I have been have trouble with this for to long. So if someone could
provide me with some insight, that would be helpful.

Thanks

In the BeforeUpdate event of the TextBox..

If DCount("*", "TableName","[account number] = " & Me.TextBoxName & "") > 0
Then
MsgBox "Duplicate Number"
Cancel = True
End If

The above assumes account number is a numeric field. If Text you will need
to add single quotes to the expression.
 
Back
Top