Checking if subform is displaying record (also posted on forms)

S

Sergio

Hi,

I'm hoping someone can help me out. I've also posted this
on the FORMS category, not sure which is more
appropriate...

I have a main form with 4 subforms. When the main form
loads, I need to check each subform to determine if it is
displaying a record. If any of the subforms are
displaying records, I need to set their "Allow additions"
option to "NO". I've tried to do this using
RecordsetClone in the current event of the main form, but
I get an error stating that the subform cannot be found.

The reason I'm trying to do this is that I need to limit
the users so they can only create one record per subform,
per form. I can't set the "allow additions" to "NO" as a
default value because if there isn't a record already
available for the subform to display, it won't display at
all and users can't add records.

Thanks

-Sergio
 
T

TC

Hmm, this sounds familiar!

This code (in the main form) will tell you whether the subform in a subform
control named sf1, has any records. (Note: you only need the name of the
subform >control<. You do not need the name of the form >within< the subform
control.)

(untested)

if me![sf1].form.recordsetclone.recordcount > 0 then
msgbox "yes"
else
msgbox "no"
endif

PS. Sergio, if you need to post to several groups, please send your post
once<, including >all< the relevant newsgroup names in the Newsgroups: line
of that one post. That's called cross-posting, & is allowed. But you have
multi-posted, which is, sending the same message seperately to different
groups. Multi-posting is bad, & wastes everyone's time. Search the web for
the terms cross-post, multi-post, or "netiquette", for more information on
these issues.

HTH,
TC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top