Results 1 to 6 of 6

Thread: Filter Question

  1. #1
    Join Date
    Oct 2007
    Posts
    214

    Question Unanswered: Filter Question

    I have a main form with a field called Locations. When I click a button on my main form with the textbox locations, another from pops up and there is a field on that form called locations. This field contains a number found in my locations text on the main form. How can I get this to be filtered to display only records that contain the number that is in locations on the main form? I'm assuming a WHERE and LIKE statement but I can't seem to perfect it.

    Any help would be great

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    For opening the second form, use:
    Code:
    Dim strCriteria as String
    strCriteria = "Locations = " & Me![textbox locations].Value
    DoCmd.OpenForm FormName, , , strCriteria
    Replace textbox locations by the actual name of the textbox.
    Have a nice day!

  3. #3
    Join Date
    Oct 2007
    Posts
    214
    Unfortunately it did not work. I believe it is because data in the one text box for example would read "Office 2250" and on the other forms text box it would just read 2250. So, It does not need to match the whole field just the number part. Any suggestions? Thanks!

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    As above except
    "Locations like `%" & me![textbox locations].value & "%`"
    ..is the iso standard wild card
    If that fails try * in place of %
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Oct 2007
    Posts
    214
    Tried both examples and a "enter perimeter box pops up with ...

  6. #6
    Join Date
    Oct 2007
    Posts
    214
    2nd time is a charm. It worked.

    Dim strCriteria As String
    strCriteria = "Locations like '*" & Me![Locations].Value & "*'"

    Many Thanks!

Posting Permissions

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