Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Dec 2000
    Location
    Huntsville AL usa
    Posts
    35
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Find Box won't go away. (2003 SP2)

    I have a form that contains a button designed to find a particular record. The 'find' is based on the 'PCR' number found in the record.

    Behind the button, I have an 'On Click' event procedure. The procedure has the following code.

    Screen.PreviousControl.SetFocus
    DoCmd.GoToControl "txtPCR" 'set focus to the field.
    SendKeys "%hw%n", False 'SendKeys "%ha%n", False
    DoCmd.RunCommand acCmdFind

    When pressed, the button properly brings up a Find box set on the correct field. The user can enter a PCR number and get the proper record displayed. My frustration is that I have been unable to cause the Find box to disappear after the find action.

    After fooling with this for a long time, off and on, I have decided to go to the EXPERTS. I just know that one of you can solve my dilemma in a nanosecond. :-)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Find Box won't go away. (2003 SP2)

    The user can click the Cancel button or press Esc to close the dialog.

    If you want to prompt the user for a search string, then continue the code, you shouldn't use the Find dialog. Use InputBox instead:
    <code>
    Dim strSearch As String
    DoCmd.GoToControl "txtPCR" 'set focus to the field.
    strSearch = InputBox("Enter string to search for")
    If strSearch = "" Then Exit Sub
    DoCmd.FindRecord FindWhat:=strSearch, Match:=acAnywhere</code>

  3. #3
    Lounger
    Join Date
    Dec 2000
    Location
    Huntsville AL usa
    Posts
    35
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Find Box won't go away. (2003 SP2)

    Thank you Hans for the guidance. And congratulations on over 50,000 posts!! :-)

    I had selected the Find box because it keeps a list of the previous finds. That allows me to reselect a previous record in the same session.

    I think that I will move on now. Your comment exhausts my efforts to close this Find box automatically.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Find Box won't go away. (2003 SP2)

    Thanks!

    Unfortunately, there is no way for your code to know when the user has finished searching using the Find dialog, so you'll have to rely on the user closing it.

Posting Permissions

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