Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2005
    Posts
    11

    Exclamation Unanswered: Closing a form on Lost Focus

    How do I get a form to close when it loosses focus, I have tried putting a close macro in both Lost focus and Deactiviate, but it returns "Action Failed"

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    You could try something like this:

    Use the well known IsLoaded function within the Activate property of the Form that is actually gaining focus.

    For example:
    Code:
    Private Sub Form_Activate()
       If IsLoaded("TheFormThatMayBeLosingFocus") Then
    	  DoCmd.Close acForm, "TheFormThatMayBeLosingFocus"
       End If
    End Sub

  3. #3
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    closing a form on lost focus

    the event OnLostFocus should work. Are you sure something else isn't happening which is preventing this from working?

  4. #4
    Join Date
    Jan 2005
    Posts
    11
    I will try that If statement, but I can't figure out why lost focus doesn't work, because it works for minimise just not for close.

    Its probably something simple that I'm over looking

  5. #5
    Join Date
    Jan 2005
    Posts
    11
    DoCmd.Close acForm, "name of form", acSaveNo

    I used the above code in on Lost Focus, and I got, 'this action cant be carried out while processing a form or report'


    I have no other active functions occurring, so I can't understand the conflict.

    any suggestions

  6. #6
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Can't Close

    Seems like something is going in code or with the form. There shouldn't be anything which causes this error unless some action is being performed. But I may be wrong.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •