troubleshooting Question

Ms Access Need Help Altering and Combining Code For Subform Limit Record Count and Allow Additions True or False

Avatar of Dustin Stanley
Dustin Stanley asked on
Microsoft AccessVBA
11 Comments2 Solutions89 ViewsLast Modified:
These are the two codes I have:

Limit Record Count in Contentious Subform:
Private Sub Form_Current()

Dim intMaxNumRecs As Integer
    intMaxNumRecs = 1 'Max Number of Records to Allow

    If Me.NewRecord Then
        With Me.RecordsetClone
            If .RecordCount > 0 Then
                .MoveLast:  .MoveFirst
                If .RecordCount >= intMaxNumRecs Then
                    MsgBox "You can't add more than " & intMaxNumRecs & " record of Quantity for each product condition!", vbInformation, "Warning"
                    Me.Bookmark = .Bookmark
                End If
            End If
        End With
    End If
End Sub

And For AllowAdditions:
Private Sub Form_Current()
If Me.RecordsetClone.RecordCount >= 1 Then
Me.AllowAdditions = False
Me.AllowAdditions = True
End If
End Sub

I would like for the code to remove the New record line after the Max Number of Records to Allow. I have tried a few different ways but not working for me. Thanks!
Join our community to see this answer!
Unlock 2 Answers and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros