Close Popup form when it looses focus

A

Anne

I am using a double click event on a field in a subform to bring up a popup
form, which displays more detailed data about the current location of plants.
When the popup forms opens, the focus is on the first field of the popup
form.
I would like for the popup form to automatically close when I click back to
the subform. I tried the forms lost focus event, but that does not work.
 
A

Anne

I tried using Deactivate Events :
DoCmd.Close
It get run-time error 2585. This action cannot be carried out while
processing a form or report event.
 
A

Anne

Private Sub Form_Deactivate()
DoCmd.Close acForm, "SfrmLotContForm"
End Sub
Still get the same message
 
O

Ofer Cohen

Sorry, you are right.
This code can't be run there, if you got the IsLoaded function in your MDB,
run this code on the Activate event of the second form

If IsLoaded("SfrmLotContForm") then
DoCmd.Close acForm, "SfrmLotContForm"
End If
 
O

Ofer Cohen

Hi Anna, I have to Apologize, because I shouldn't just guss where the code
should be in.
Any way I tried it, and there is no event in the either of the forms that
trigger the code, except two places, and it's going to be quite anoying.
1. The OnClick event of the first form
2. Got focus event of the fields in the first form
 

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