Limit amount of data in an Access table |
11/18/2006 10:41:35 AM |
ASPRunnerPro General questions | |
author
I was wondering if there is a simple way to limit the amount of records |
|
C
|
clig 11/18/2006 |
I was wondering if there is a simple way to limit the amount of records allowed into a table. I would like the user to receive a message that they are at capacity for this table. An example would be if a student was signing up for a class and the class was at its limit...they would receive a message. Anything would be great. Thanks <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=13003&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' /> <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=13003&image=2&table=forumreplies' class='bbc_emoticon' alt=':D' /> jmager Ok, I think I found my answer....searching is a powerful weapon <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=13003&image=3&table=forumreplies' class='bbc_emoticon' alt=':D' />
|
|
501274 11/19/2006 |
Thank you, that worked great. I found this on a search of the asprunner forum. Will this work with MSAccess? Thanks again for the help <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=13010&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' /> Something like this in Before record added and a backend of SQL Server (DCOUNT maybe better for MSAccess): Function BeforeAdd(dict) ' Parameters: ' dict - Scripting.Dictionary object. ' Each field on the Add form represented as 'Field name'-'Field value' pair '** Custom code **** ' put your custom code here set CN = server.CreateObject("ADODB.Connection") CN.Open "DSN=NTSS;UID=sa;PWD=xxx" set rs = Server.CreateObject("ADODB.Recordset") rs.Open "SELECT COUNT(Action_Item_ID) AS RecordCount FROM dbo.Action_Items", CN If int(rs("RecordCount")) > 20 Then Response.Write "Too Many Records: " & rs("RecordCount") & " - Max of 20 records allowed." Exit Function Else End If rs.Close BeforeAdd = True ' set BeforeAdd to True if you like to proceed with adding new record ' set it to False in other case End Function |
![]() |
Sergey Kornilov admin 11/19/2006 |
Yes, this will work with MS Access. |
|
501275 11/19/2006 |
Yes, this will work with MS Access.
|