Ms Access Need Help Altering and Combining Code For Subform Limit Record Count and Allow Additions True or False
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" .MoveLast Me.Bookmark = .Bookmark End If End If End With End IfEnd 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!
so would I just drop this into the subform VBA and all the events will take place as needed?
Gustav Brock
No, you will save it in a code module and refer to it from your subform as explained in the in-line comments.
/gustav
Dustin Stanley
ASKER
Ok I see. Sorry I was on my mobile at the time and couldn't visualize it until I made the module on my PC. But there is an issue and it is the same for this code as it was doing earlier with my code. If I click the record selectors on the main form the next record subform (If New Record) is blank and I can't add any records to the subform at all not even up to the lngRecordsMax.
I take that back. All the records before and after have the New Record Line Gone whether it is new or only has 2 records and the lngRecordsMax is set at 5