How do I restrict number of records in form?

satisharalkar

Registered User.
Local time
Today, 22:51
Joined
Jan 14, 2006
Messages
14
Hello,
My "customer" form is based on sigle table. I have to restrict no of customers only 5 customers. can anybody help me ?
This is required for distributing a database.

Regards,

Satish
 
Put this in the OnCurrent event of your form.
Code:
If Me.NewRecord = True And Me.RecordsetClone.RecordCount = 5 Then
    MsgBox "You have reached 5 records", vbCritical, "Limit Reached"
    Me.Form.AllowAdditions = False
Else
    Me.Form.AllowAdditions = True
End If
End If
 
I would enforce the rule at the table level. Use a numeric primary key and restrict the value to >=1 and <=5.
 

Users who are viewing this thread

Back
Top Bottom