By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,335 Members | 2,218 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,335 IT Pros & Developers. It's quick & easy.

Display subform problem

P: n/a
I have a simple form/subform arrangement with a 1:M relationship. I want to
limit the number of records at the many end to a maximum of 4 per "main"
record - what's the best way? I've tried this code in the subf's current
event:

If Me.RecordsetClone.RecordCount = 0 Or Me.RecordsetClone.RecordCount < 4
Then
Me.AllowAdditions = True
Else
Me.AllowAdditions = False
End If

but if I navigate from a record with 4 in the subf to a record with none in
the subf, the subf's controls aren't displayed. I know that this is because
the subf's current event hasn't fired and the AllowAdditions property is
still False but I'm stumped as to how to overcome this.

I know I should really know the answer to this but my brain's gone on
holiday early this year.

Many TIA - Keith.
Jul 27 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Keith

Cancel the BeforeInsert event of the subform, it a DCount() indicates there
are already 4 records or more for this foreign key value.

(I suggest a DCount() rather than RecordsetClone.RecordCount in case some
smart user figures out they can filter the subform.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Keith Wilby" <he**@there.comwrote in message
news:44**********@glkas0286.greenlnk.net...
>I have a simple form/subform arrangement with a 1:M relationship. I want
to limit the number of records at the many end to a maximum of 4 per "main"
record - what's the best way? I've tried this code in the subf's current
event:

If Me.RecordsetClone.RecordCount = 0 Or Me.RecordsetClone.RecordCount < 4
Then
Me.AllowAdditions = True
Else
Me.AllowAdditions = False
End If

but if I navigate from a record with 4 in the subf to a record with none
in the subf, the subf's controls aren't displayed. I know that this is
because the subf's current event hasn't fired and the AllowAdditions
property is still False but I'm stumped as to how to overcome this.

I know I should really know the answer to this but my brain's gone on
holiday early this year.

Many TIA - Keith.

Jul 27 '06 #2

P: n/a
"Allen Browne" <Al*********@SeeSig.Invalidwrote in message
news:44***********************@per-qv1-newsreader-01.iinet.net.au...
Hi Keith

Cancel the BeforeInsert event of the subform, it a DCount() indicates
there are already 4 records or more for this foreign key value.

(I suggest a DCount() rather than RecordsetClone.RecordCount in case some
smart user figures out they can filter the subform.)
You deliver as per usual Allen, many thanks indeed.

Regards,
Keith.
Jul 27 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.