Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DoCmd.Domenuitem (97)

    I have a subform displaying a set of records from a combo box that run off of about 20 separate queries.

    I have added a button with this behind it. :- DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
    Which basically gives me a search box, after setting the focus to the subform.
    One problem with this , is that several options seem to be already set for this 'find' box, ie: it defaults to 'Match Whole field' and the bottom check box.


    The fields dsiplayed are set out like this: GB-001/TG/003.S55 (number field) How to make sausage pie (text field)


    What i really want to do, for the search criteria.. is to display ALL records with the search string.

    I presume i could write a query . and tie the criteria of the query into a text box using 'Like' [textbox] ?

    Or is there an easier/better way ?


    Regards

    Steve

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

    Re: DoCmd.Domenuitem (97)

    In the first place, DoMenuItem is a leftover from older versions of Access. It's better to use RunCommand to run menu items in code. In this case:
    RunCommand acCmdFind. You may find the thread starting at <post#=144175>post 144175</post#> useful if you want to know more about setting options for finding.

    But from your description, I guess you want to filter records instead of finding them. The built-in methods (Selection Filter, Form Filter and Advanced Filter) provide a good range of filtering options, from simple to advanced. If you want to use a textbox, you can set the filter of the (sub) form:

    <font face="Georgia">MySubForm.Form.Filter = "FieldName Like " & Chr(34) & [TextBox] & "*" & Chr(34)
    MySubForm.Form.FilterOn = True</font face=georgia>

    Chr(34) is a quote; the text to be filtered must be enclosed in quotes.

  3. #3
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DoCmd.Domenuitem (97)

    Hans , I tried this and got a error 13, type mismatch error. I tried all the combinations i could think of also..

    i was using :-

    Doc_Library_Subform.Form.Filter = "Document Link Like " & " & [Search_Box] & "*" & "

    The 'Fieldname is two words' does this matter? its the text of a hyperlink field.

    Steve

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

    Re: DoCmd.Domenuitem (97)

    Just using a " instead of Chr(34) won't work. And you must enclose field names that contain spaces in square brackets. Replace

    Doc_Library_Subform.Form.Filter = "Document Link Like " & " & [Search_Box] & "*" & "

    by

    Doc_Library_Subform.Form.Filter = "[Document Link] Like " & Chr(34) & [Search_Box] & "*" & Chr(34)

Posting Permissions

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