473,414 Members | 1,631 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Limit the number of new records a user can enter

Access 97: I have form that is has a sub-form embeded in it, I would like to limit the number of records that the user can enter into the sub-form to 5 entries. Is this possible? If so, how?
Thanks
Woody
Jun 8 '07 #1
2 3347
ADezii
8,834 Expert 8TB
Access 97: I have form that is has a sub-form embeded in it, I would like to limit the number of records that the user can enter into the sub-form to 5 entries. Is this possible? If so, how?
Thanks
Woody
Yes it is. In the BeforeUpdate() Event of the Sub-Form, place the following code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2. Dim Msg As String
  3.  
  4. Msg = "You are at the Maximum Allowable Number of Records in this Sub-Form. The "
  5. Msg = Msg & "Save Operation will be cancelled!"
  6.  
  7. If DCount("*", "tblWorkEmployment", "[PayrollNumber]=" & Me.Parent![PayrollNumber]) = 5 Then
  8.   MsgBox Msg, vbCritical, "Maximum Number of Entries"
  9.     Me.Undo
  10. End If
  11. End Sub
  12.  
WHERE:
  1. tblWorkEmployment is the RecordSource for your Sub-Form.
  2. [PayrollNumber] is the Linked Child Field in the Sub-Form.
  3. Me.Parent![PayrollNumber] refers to the Master Linked Field (1 to MANY to the Child Linked Field in the Sub-Form).
  4. Any other questions, feel free to ask.
Jun 8 '07 #2
Thank you for your help!!

Yes it is. In the BeforeUpdate() Event of the Sub-Form, place the following code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2. Dim Msg As String
  3.  
  4. Msg = "You are at the Maximum Allowable Number of Records in this Sub-Form. The "
  5. Msg = Msg & "Save Operation will be cancelled!"
  6.  
  7. If DCount("*", "tblWorkEmployment", "[PayrollNumber]=" & Me.Parent![PayrollNumber]) = 5 Then
  8.   MsgBox Msg, vbCritical, "Maximum Number of Entries"
  9.     Me.Undo
  10. End If
  11. End Sub
  12.  
WHERE:
  1. tblWorkEmployment is the RecordSource for your Sub-Form.
  2. [PayrollNumber] is the Linked Child Field in the Sub-Form.
  3. Me.Parent![PayrollNumber] refers to the Master Linked Field (1 to MANY to the Child Linked Field in the Sub-Form).
  4. Any other questions, feel free to ask.
Jun 11 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: JohnH | last post by:
I have an ASP app (developed with Interdev 6) which uses a DTC listbox (server-side) bound to a recordset to allow the user to make a selection. This works fine until the number of records in the...
2
by: Dalan | last post by:
I am finalizing an Access 97 db and need to decide was is the best method to limit the number of records one can enter in the demo version of same. The archives seem to be replete with many...
6
by: Hannu | last post by:
Hi. In the ldb file you can see the users of the mdb-file. If you open the mdb-file your machine and username will be written in the lbd- file. Allthough you close the mdb-file your name won't...
3
by: deko | last post by:
Is there any way to limit the number of records loaded into a ListBox? I looked at qdf.MaxRecords (to apply to the query that is the RowSource of the ListBox) but that only applies to ODBC data...
4
by: Melson | last post by:
Hi I've a problem. Can anyone help. I would like to use datagrid for data entry. How can I set the number of rows in the datagrid. And use the datagrid to update the ms sql table. regards...
2
by: OM | last post by:
I have two tables, one with categories in it, and only 3 records - Wages, Salary, Contract. I have a second table that records hours and numbers of employees in each category, per month. How do...
1
by: dfw1417 | last post by:
I have used a query and report filter to return records related to a specific account id. I want to print a report including only the latest 6 records out of the set returned by the record filter. I...
1
by: | last post by:
Hello everyone, I am using a textbox for dumping information generated by the file system watch object. I am having this problem that always at some stage new new information stops being entered...
4
by: ghjk | last post by:
I have php web application and there I have php page for entering stations(Like user). But I want to limit the Number of records. User can only enter the 30 records. How can I limit that?
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.