Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fixed record number

Status
Not open for further replies.

Mandrutza

Programmer
Feb 12, 2002
34
RO
I would like to know if there is a way to limit a table to contain, for example maximum 5 records. Pls help !! I hope that tomorow I'll still be alive and kicking.
 
I don't think there's an intrinsic restriction in a table for this kind of thing, but you can do it with code. I'll give an example, and you can modify this to fit your situation (This code would be on a form bound to your table.):
Code:
Private Sub Form_BeforeInsert(Cancel As Integer)
    If Me.RecordsetClone.RecordCount = 5 Then
        MsgBox "Nope!"
        Cancel = True
    End If
End Sub
Basically, before a new record is inserted, you check to see if your table already has 5 records. If so, then cancel the insert and alert the user. Piece of cake, right? :)

--Ryan
 
Piece of cake? Not for me.I'm new to this and I cannot understand how to do it. I should better explain my problem. I have a web interface in wich I give to other users acces to an Access table.It creates an Access table for each user and I cannot change the interface to limitate the number of records in each table. This property must be set in db.I do not know how. Pls help! I hope that tomorow I'll still be alive and kicking.
 
Oh. Well, you stumped me there. I don't know of any way to limit the number of records a table has in the table itself. Anyone else?

--Ryan
 
So, nobody have any ideea? I hope that tomorow I'll still be alive and kicking.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top