Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limiting the number of subform records

Status
Not open for further replies.

AKBirder

Technical User
Joined
Apr 30, 2008
Messages
4
Location
US
I am using the following code in a subform to limit the number of enteries:

form_beforeInsert event:

If Me.Recordset.RecordCount = 3 Then
MsgBox "Maximum 3 line items can be entered!"
Cancel = True
End If

Now what I want is to replace the "3" with an user inputed value from the main form.

ex. If Me.Recordset.RecordCount = [forms]![frm_MAIN]![controlname].....

What would be the proper way to do this?
 
Parent is good.

Code:
If Me.Recordset.RecordCount = Me.Parent.txtText Then
        MsgBox "Maximum 3 line items can be entered!"
        Cancel = True
    End If

you may wish to consider the Current event (On Current) and the NewRecord Property (Me.NewRecord), rather than Before Insert.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top