Limit Subform to one record

jharding08

Member
Local time
Yesterday, 23:35
Joined
Feb 16, 2021
Messages
55
I have a subform that has three fields - Start Date, End Date and Duration. It comes from a table that has many records, so the recordset is Select Top 1 (although there should only be one).

This subform should be able to allow for new entries, but just one, so I have to set the Allow Additions to Yes, right? If I set Allow Additions to No and there isnt a current record, it doesnt show the fields. I just want one record for this subform, but when I enter new or edit the current record and hit enter, it goes to a new record. Is there a way to limit this on New/Edit?
 

Me.allowadditions = (me.recordset.recordcount = 0)
 
Check the form recordset count?
If zero, set AllowAdditions, else leave it disabled. Check again after record entered.
 
In the sub on current event.
 

Me.allowadditions = (me.recordset.recordcount = 0)
I'm running into an issue where if I create a new parent record, this logic isnt working because I use the link master/child field property in Access, so the recordset may be 1, but for that parent record it is 0.

Could I update the code to account for this second filter?
 

Users who are viewing this thread

Back
Top Bottom