Results 1 to 3 of 3
  1. #1
    mkfloque is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    24

    Set maximum count of records


    Hello All,

    In a table/form, i'd like to make sure that each study ID has no more than 3 questionnaires. So, basically, in this particular table/form, the max count for each study ID should be 3. Any ideas on how to do? Thank you!

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    I don't think it can be done at the table level but should be easy enough if done at the form level. Any data being added to tables or existing data being edited should with a form anyway.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Further to Bob's assertion regarding forms:
    If you're using a temp table like I was, you can check the number of records. This uses the form textbox control txtNPno as criteria for the count, and runs on the BeforeInsert event.
    Code:
    If DCount("*", "tempNPitems", [NPno] = Me.txtNPno) > 6 Then
      MsgBox "Only six records allowed!", vbOKOnly
      Cancel = True
    End If
    I guess you could do the same thing against your form or subform if it's a datasheet, or against your main table using your study ID as criteria.
    Last edited by Micron; 06-21-2016 at 10:17 AM. Reason: clarified event
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Maximum number of records shown in a report
    By gaker10 in forum Reports
    Replies: 3
    Last Post: 10-23-2015, 01:12 PM
  2. Maximum Nos of Records
    By abusaif in forum Access
    Replies: 2
    Last Post: 11-01-2014, 08:03 AM
  3. Replies: 2
    Last Post: 07-24-2014, 03:37 PM
  4. Replies: 1
    Last Post: 12-20-2013, 05:14 PM
  5. COUNT Group Count Records COUNT FUNCTION
    By PMCOFFEY in forum Access
    Replies: 9
    Last Post: 11-09-2012, 09:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums