Results 1 to 11 of 11
  1. #1
    Mike505 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2022
    Posts
    19

    Close Find dialog box programmatically (VBA)

    I have a form that displays a Find dialog box using: DoCmd.FindRecord " ", acStart, False, acSearchAll, False, acCurrent, False



    The user finds the first entry, goes to the next, etc, etc, and eventually finds the one that he wants.
    At this point he starts to modify the entry.

    I know when that happens (the modifications begin) and I want to programmatically "click" the cancel button in the Find box.
    Since there's a way to programmatically invoke the Find box, can anyone think of a way to get rid of it.

    The issue is that the user can make changes to the first entry that he stops at and then go the next entry and make changes there as well.
    That's what I want to prevent. Once changes start, no other records can be accessed.

    Mike

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I am trying this code. No dialog displays, focus just goes to first record that matches, if any.

    And when the dialog closes, nothing would prevent user continuing to edit records. Shouldn't user already know what they need to edit and to quit when it's done? So I don't really understand what you want to accomplish.

    Review http://allenbrowne.com/ser-62.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,563
    Hi Mike

    As June has already said, the users of the database should know that when they locate a specific record they would edit as necessary and then exit the form.

    Qhy are you trying to add additional complexity ?
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  4. #4
    Mike505 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2022
    Posts
    19
    Here's the issue:

    A user gets to record X and makes a change then goes to record Y and makes a change and finally to record Z and makes a change then click Undo Changes.
    Which record(s) get undone.
    I wasn't even sure until I tried it and then I seem to get varying results.
    So I look at this as a way to eliminate the question "What am I undoing" and the simplest way to do that is to not allow updates to multiple records from the same find box.

    It may seem like I'm adding complexity but this application is in 5 locations and there are about 50 people/location using it to modify data after finding the data thru a Find Box.
    So for me adding complexity is trying to train 250 people on "what they should know".
    Simplifying things is preventing the problem in the first place.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    What varying results? This is a command button? What code?

    Data validation should be done with each record, once accepted why would there be a need to 'undo' two record edits later?

    I do not get the behavior you describe - no dialog opens.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Mike505 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2022
    Posts
    19
    This is getting off-topic. The original question was and still is do you know how to programmatically close a find box.
    If someone can answer that question, that would be great.
    If not, I'll assume it can't be done or no one reading this post knows how to do it.

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    I think you would have to upload a sample DB, as no one seems to be able follow your logic or your process.?
    FWIW the last record would have it's changes rolled back, the others would be saved when you move on to a new record.

    Perhaps you should filter instead?, then you would only get that hopefully one record if the filter criteria is unique?
    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

  8. #8
    Mike505 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2022
    Posts
    19
    I can't filter more finely because the user often only knows that the search field starts with some value.
    So they need to be able to step thru the find results looking for what they want.

    If they change record 1 and go to record 2 and change it and then undo the change on record 2,
    only record 2 is undone.

    If they change record 1, go to record 2 and don't change it but request an undo, the change to record 1 is undone.

    You may wonder why I care and the answer is that I don't like phone calls where someone complains about
    something and I have to admit to myself that they have a point.

    So I'm back to my original request because forcing the Find box to close as soon as they start to modify
    the first record that they settle on will take care of all of this.

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    I think we do not understand this find dialogue?
    June7 states no dialogue appears when your code is used. I have not tried, but have difficulty thinking of a separate dialogue?
    All i can think of without any concrete example is when you find a record, set the form filter to that immediately, with a way out to remove filter?, or instruction on using the ribbon to do the same?
    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

  10. #10
    Mike505 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2022
    Posts
    19
    Since I was unable to find a way to programmatically cancel a Find dialog box, I used the Private Sub Form_Current() interrupt to accomplish what I wanted to do.

    Every record in the table has a unique Record ID (1,2,3).
    I keep track of the current and previous Record ID every time the Form_Current code is invoked and I keep track of the fact that someone changed a record.

    If someone searches via a find box using a non-unique field (name, state), and they change Record ID 7 and then do a Find Next to Record ID 28,
    I tell them they can't do that and I force an Undo. Since they haven't changed anything in Record ID 28 yet, the Undo is applied to Record ID 7.

    At this point they can Update 7 or go to 28.

    The problem was that there was a lot of editing done that was associated with the Update button and that was getting bypassed going directly from 7 to 28 without first
    using the Update button on 7.

    The same problem resulted from exiting the screen after making changes and this approach fixed that as well.

    If someone finds this helpful, that's great.
    If people still find that I'm over-complicating things, then I give up.

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    As long as you are happy with the solution.
    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

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

Similar Threads

  1. Requerying on close of dialog form - optional?
    By Historypaul in forum Forms
    Replies: 2
    Last Post: 01-07-2015, 04:02 PM
  2. Close Dialog Box instead of Close App
    By ccchan in forum Access
    Replies: 4
    Last Post: 03-19-2014, 08:34 AM
  3. Replies: 1
    Last Post: 09-19-2013, 11:42 AM
  4. Can't cancel the ‘find’ dialog in modal form
    By AndrewAfresh in forum Access
    Replies: 0
    Last Post: 09-23-2011, 11:12 AM
  5. How to restore Find dialog in Access
    By AndyKim in forum Access
    Replies: 11
    Last Post: 06-25-2009, 11:28 AM

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