Results 1 to 4 of 4
  1. #1
    Join Date
    May 2011

    Unanswered: Restrict Record Count

    Hi to all,
    Please can somebody kindly tell me a step by step process to restrict my ms access database record to accept only five records through the form interface and after that if the user trys to input the sixth records, it tell the user that he or she has exceeded the amount of permitted records ant that it is a demo version. Purchasing the original will cause it to run normal.
    Thank you.

  2. #2
    Join Date
    Mar 2009
    This could be achieved using VBA on the AfterInsert event. Just test the recordcount against your set variable (I would hide this somewhere in code) and then when the maximum is reached set the form property called AllowAdditions to false. You should also test the number of records when the form opens.


  3. #3
    Join Date
    May 2010
    I like to use the form's On Current Event. If the record count = the max allowed then set the form's allow additions to false.
    Boyd Trimmell aka HiTechCoach (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  4. #4
    Join Date
    Jun 2005
    Richmond, Virginia USA
    Provided Answers: 19
    I'd use a little bit of both suggestions!

    I agree with Boyd about the use of OnCurrent for this.

    And rather than hiding a variable somewhere in code, as Software Matters suggested, I'd use the Tag Property of Form to hide it. In Form Design View, with the Form itself selected, go to Properties - Other and in the Tag Property box enter 5, or however many records you'd like to allow. Then use this code:

    Private Sub Form_Load()
     DoCmd.GoToRecord , , acLast
     DoCmd.GoToRecord , , acFirst
    End Sub
    Private Sub Form_Current()
      If Me.NewRecord Then
       If Me.RecordsetClone.RecordCount = Val(Me.Tag) Then
        Me.AllowAdditions = False
        MsgBox "You Must Register This Product To Continue!"
        Me.AllowAdditions = True
       End If
      End If
      End Sub
    From my experience, a large of Access developers aren't really aware of the Tag Property, and certainly no non-developers are going to know about it, and I've found it a great place to 'hide' stuff!

    Of course, to be truly secure you'd need to distribute your app as an MDE or ACCDE file, where the users couldn't access the code at all.

    Linq ;0)>
    Hope this helps!

    The problem with making anything that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts