Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2022
    Posts
    4

    Question How to Close the "Find" form

    I can use the following vba to Open the Find form (dialog?):

    DoCmd.RunCommand acCmdFind



    Many of our users click Ctrl + F to also open the Find form; unfortunately, after finding the desired record, they click on another command button without closing the opened Find form. Later, they often find it still open when they close a form. I'd like to add vba to the command button that closes the opened Find form.

    Can anyone provide me with the vba to Close this command form?

    Thanks in advance.

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Perhaps cycle through all open forms and debug.print form name, and see what it is called?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Join Date
    Feb 2022
    Posts
    4
    I tried:

    Sub AllForms()
    Dim obj As AccessObject, dbs AsObject
    Set dbs = Application.CurrentProject

    ' Search for open AccessObject objects in AllForms collection.
    For Each obj In dbs.AllForms
    If obj.IsLoaded = True Then
    ' Print name of obj.
    Debug.Print obj.Name
    End If
    Next obj
    End Sub

    It returned the name of the opened form but not the Find form. So it apparently isn't a "form", not sure exactly what it is. If it's a dialog, I don't know how to cycle dialog objects to discover which are open.

  4. #4
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    You must not be opening it as dialog as you questioned, otherwise you would not be able to open any other object until that one is closed. In fact, the calling code would 'hang' until that happens. You could open form in design and set modal property to True (yes) also.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Join Date
    Feb 2022
    Posts
    4
    Micron,

    Now that I try it, I the find dialog appears to close when we click a commond button on the form that opens another form?

    I know I've worked with users where we found the Find dialog open after we clicked on the button to open another form ... but I can't get it to do it again!

    I guess, I'll forget about it unless it reoccurs. It does stay open once it finds a record but now disappears when we click the command button to open another form.

    Feel like I must be smoking something

    Thanks. I don't know how to show your response as an answer, but for now it is.

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Thanks. I don't know how to show your response as an answer, but for now it is.
    Thread Tools in the menu bar on the top right of the thread.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    Just a side note, you might want to consider replacing the built in Find and Replace dialog you're currently using with a custom pop-up and \or modal form that you can easily control. Here is an older discussion on the topic:
    https://bytes.com/topic/access/answe...blem-accmdfind

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  8. #8
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Well it seems I misinterpreted this
    they click on another command button without closing the opened Find form.
    to mean you were using a form. If you mean it's what you get when you use a context menu or ribbon menu (or keyboard shortcut for the same), then I don't know. I think you were more accurate to call it a dialog. I don't suppose it really matters if it remains open, but your form close code could probably take care of it.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. "Close form" action does not release table
    By TFisher in forum Programming
    Replies: 8
    Last Post: 10-23-2022, 11:54 AM
  2. Replies: 3
    Last Post: 07-07-2016, 12:22 PM
  3. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  4. Lost in loop preventing close from "X" on form
    By Chris033115 in forum Forms
    Replies: 5
    Last Post: 04-16-2015, 01:51 PM
  5. Replies: 5
    Last Post: 09-01-2014, 12:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums