Syntax problem?

  • Thread starter Thread starter David Hunt
  • Start date Start date
D

David Hunt

Is there an easy way to code the following...

I'm looking for the easy way to code the "If Form is empty
then" statement...

DoCmd.OpenForm "Form"

If Form is empty then
Do X...
Else
Do Y...
End If

thanks much
 
If the form does not have any code behind it, try this:

docmd.openform "Form"
if forms("Form").recordsetclone.eof then
' form has no records.
else
' form has records.
endif

That is a rather crude solution. It will only work immediately after the
openform call. It might not work if the called form has any code in the
Form_Open or Form_Close events. There are other (better, safer) methods, but
perhaps that would do for starters.

BTW #1, if the called form is a modal form, you will not get back from the
openform call until the user has *closed* the called form.

BTW #2, I hope your form is not actually called "Form"?!

HTH,
TC
 
Back
Top