Lost Focus or On Deactivate

  • Thread starter tobesurveyor via AccessMonster.com
  • Start date
T

tobesurveyor via AccessMonster.com

Hello all,

I have two forms, Form A and Form B. When I click on a control on Form A, I
have code to open Form B (Form B takes up only a portion of the screen, while
Form A has been maximized). When I click on Form A while Form B is open, I
would like for Form B to close. I have tried DoCmd.Close acForm, "FormB",
acSaveNo in the Lost Focus Event and the On Deactivate Event of the form.
Each time getting an error.

Could someone point me in the right direction of how to do this? Is there a
function besides DoCmd.Close that will need to be run?

Thanks,
Chris
 
D

Douglas J. Steele

What's the error you're getting?

You might try putting the code in the Activate event of Form A.
 
K

Ken Snell \(MVP\)

Did you set the On Deactivate property to "[Event Procedure]" and then put
your code in the form's module for the Form_Deactivate procedure?

Using the Deactivate event is correct, and the VBA code step that you posted
also is correct.
 
B

Brendan Reynolds

You have the right command, but the wrong event. Try using the Activate
event of Form A.
 
T

tobesurveyor via AccessMonster.com

Thanks to all that posted. It works great now that I followed the suggestion
of putting it to the Activate event on Form A.

Thanks again.
Chris

Brendan said:
You have the right command, but the wrong event. Try using the Activate
event of Form A.
Hello all,
[quoted text clipped - 14 lines]
Thanks,
Chris
 

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