On the Receipts form in the app, the intent is to limit the amount of records on the sub form to 1. The VBA in red works well. It is placed on the Sub form.
The question here is; I only want this restriction if field txtTratyp_IDd <> 1510.
Private Sub Form_BeforeInsert(Cancel As Integer)
If Me.NewRecord = True And Me.RecordsetClone.RecordCount = 1 Then
MsgBox "Only one record allowed. Select Batch Receipt if multiple deposits are made.", vbExclamation + vbOKOnly, "Perfac"
DoCmd.GoToRecord , , acPrevious
End If
End Sub
The need is to add an extra criteria or condition. But then the code does not work anymore, if this line replaces the second line in red above.
If Me.NewRecord = True And Me.RecordsetClone.RecordCount =1 And Me.txtTratyp_IDd <> 1510 Then
I found on a forum the advice below, maybe I do not apply it exactly correct.
Private Sub Form_Current()
If Me.txtTratyp_IDd <> 1510 Then
allowadditions = dcount("*"",recordsource)=1
End If