I have created a table and form for allowing the input of a unique
customer number (not an ID autonumber number) which a customer would
enter once after installing the database. I'm using DLookup to obtain
the value which works. What I need assistance with is the best method
to use to ensure that only ONE customer number can be entered. A quick
attempt to structure a piece of code is shown below. Any assistance
will be appreciated. Thanks, Dalan
Private Sub Form_AfterUpdate() ? or ?
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim RecordCount As String
RecordCount = "CustomerNo"
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblCustomerNo")
With rs
.MoveFirst
If RecordCount = 0 Or 1 Then
MsgBox "Only one Customer Number is allowed to be entered"
' Need code to limit the number of records to only 1
End If
.Close
End With
Set rs = Nothing
Set db = Nothing
End Sub