Limit entries to a form

  • Thread starter Thread starter Allen Browne
  • Start date Start date
A

Allen Browne

Cancel the BeforeInsert event procedure of the form if the maximum number of
records is already present, and the user can't give the password:
Private Sub Form_BeforeInsert(Cancel As Integer)
If DCount("*", "Table1") > 30 Then
Cancel = True
MsgBox "No more!"
End If
End Sub

To get the password, create a small unbound form with a text box that has
its Input Mask peoperty set to Password. OpenForm in acDialog mode, and if
the password string does not match, you can set a variable so that when the
form is closed and control is passed back to the previous form, it knows to
cancel the event.
 
Hello,
I have a MS-Access 97/2003 database, on a Windows XP system acting as a
server for the database.
I need to limit the number of entries (30) to a specific form, and if
necessary to enter more than 30, a password is required.
Can someone point me to some examples???


Thank you,
 
Hello,
"Thank You"...
This sounds really good. I'll try this in the morning.
Can you point me to some examples of this type???


Thank you,
 
Try the example in the reply.

If you get stuck trying to work with the unbound dialog form, post back a
reply to this thread.
 
1. Open the form in design view.

2. Open the Properties box (View menu.) Make sure the title of the
Properties box reads "Form", so you are looking at the properties of the
form and not those of a text box.

3. On the Event tab of the Properties box, set the Before Insert property
to:
[Event Procedure]

4. Click the Build button (...) beside this. Access opens the code window.

5. Add the 4 middle lines, so the code looks like this:
Private Sub Form_BeforeInsert(Cancel As Integer)
If DCount("*", "Table1") > 30 Then
Cancel = True
MsgBox "No more!"
End If
End Sub

6. Change "Table1" in the code above to the name of your table.
 
Back
Top