Close button

G

Guest

I have a form in which i have disabled the "X" close button. I want to force
people to use an "Exit" button whch saves,prints, and closes the form.
Everything works ok except when the underlying querry had no records. In this
case the staff do not see the "X" button nor can they see the "Exit" button
and have no way to close the form.
where do i put the do.cmd to close the form automatically when there are no
records to display?
 
G

Guest

On the OnLoad event of the form you can put this code

If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "No records"
DoCmd.Close
End If
 
G

Guest

It works but closes the main Startup form!!. It does not close the form that
has the above event procedure in OnLoad !! what am i missing?
 
G

Guest

Then instead of docmd.close use
docmd.Close acForm,"FormName"

Change the FormName to the name of the form you want to close
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck
 
G

Guest

Works perfectly. Thank you


Ofer said:
Then instead of docmd.close use
docmd.Close acForm,"FormName"

Change the FormName to the name of the form you want to close
--
If I answered your question, please mark it as an answer. That way, it will
stay saved for a longer time, so other can benifit from it.

Good luck
 
B

BruceM

For future reference another angle would be to print a report rather than a
form. The report has an On No Data event.
 

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