Not allow more than 3 records in subform

  • Thread starter Thread starter Joel Levy
  • Start date Start date
J

Joel Levy

TWIMC:
TIA:

Trying to not allow additional records to subform if there
are currently 3 records (ie no more than 3 records allowed
in subform).

Any ideas??

Thanks again,
Joel
 
Cancel the BeforeInsert event of the form:

Private Sub Form_BeforeInsert(Cancel As Integer)
If Me.RecordsetClone.RecordCount >= 3 Then
Cancel = True
MsgBox "No more records!"
End If
End Sub
 
You could check for .recordcount >3 and abort the update, or only allow
editing to begin if recordcount<3
 
Allen:

Thanks so much.

Joel
-----Original Message-----
Cancel the BeforeInsert event of the form:

Private Sub Form_BeforeInsert(Cancel As Integer)
If Me.RecordsetClone.RecordCount >= 3 Then
Cancel = True
MsgBox "No more records!"
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.




.
 
Allen:

had to add to If statement ...And form.newrecord=True Then

Otherwise couldn't edit any record if count was 3!!

Thanks, Joel
 
Evil TC says:

- filter to record #1 (via PK or whatever);
- add new record;
- add new record;
- re-filter to record #1;
- add new record;
- add new record;
etc!

I'd be saying, if Me.FilterOn then msgbox "Sorry, you must remove the filter
before you add a new record", etc.

Cheers,
TC
 
TC said:
Evil TC says:

- filter to record #1 (via PK or whatever);
- add new record;
- add new record;
- re-filter to record #1;
- add new record;
- add new record;
etc!

Or set AllowFilters = No at design time.
 
Back
Top