subform condition

  • Thread starter Thread starter Alan
  • Start date Start date
A

Alan

Hello,

I have a form with a subform on it that is used for data entry. What I'm
trying to accomplish is that when the main form is open, the user cannot
close it out until he/she fills something into the subform.

I thought of using a RecordSet.RecordCount method but is this the best way
to do it?

Here's the code I wrote but Access doesn't like it so I'm suspecting I'm
writing it incorrectly:

If Me!sbfmQuotePkgHeader.RecordsetClone.RecordCount = 0 Then
MsgBox ("The PACKAGE SUMMARY section is empty. Please fill in PACKAGE
SUMMARY.")
Else
DoCmd.Close
End If

Thanks in advance.

Alan
 
I guess I should clarify, what I meant is that the subform cannot be blank.
If there are records in the subform already associated to the main form, then
it's fine but if the user tries to leave the subform blank on exit, it should
stop the close action and a msgbox should appear indicating they need to fill
in the subform.
 

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

Back
Top