Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    FIND commands (97)

    Hi, I have nearly finished my database, but for one last thing!

    I have set up a command button to open the FIND dialog box, using the wizard from the control panel and i get the code:

    Screen.PreviousControl.SetFocus
    DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

    Will this work if i disable all the menus? As once the database is complete i want to do this, to restrict access etc. If not, is there another way of activating this find box with VB?

    Also, how can i get the FIND Dialog box to default to the way I want it, this being to search any part of field, not to limit to current field and so forth. I can't find any help on this in the help files.

    any ideas greatly appreciated. All i want to do is to be able to search through the current records for any instance of the search string.

    Thanks
    Thanks,

    pmatz

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

    Re: FIND commands (97)

    As far as I know, the code equivalents of menu items will still work if you disable the menus themselves. The code with DoMenuItem is a bit old-fashioned, as you can see from the acMenuVer70 argument. This is not your fault, even in Access 2002 the command button wizard still produces antiquated Access 2 and Access 95 (= version 7) code! However, there is a more "modern" equivalent:

    RunCommand acCmdFind

    (In case you are interested, see Converting DoMenuItem to RunCommand for a list of DoMenuItem equivalents.)

    There is no built-in way to control the settings in the Find dialog in code. One way is to use SendKeys, which works for specifying that you want to search any part of a field, but not (easily) for specifying that you want to search the entire form. Another way is to do a dummy search first:

    Screen.PreviousControl.SetFocus
    ' Search for something innocuous, like a space
    DoCmd.FindRecord " ", acAnywhere, False, acSearchAll, True, acAll, False
    ' Open the Find dialog
    RunCommand acCmdFind

  3. #3
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: FIND commands (97)

    Thanks Hans, thats very helpful [img]/forums/images/smilies/smile.gif[/img]

    i used this with a

    sendkeys "{BS}" to set the search area to null. This does the trick!
    Thanks,

    pmatz

Posting Permissions

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