Results 1 to 2 of 2
  1. #1
    ScottySchultz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2018
    Posts
    8

    Searching 2 fields to produce results with an OR operator

    I have a form I'm running this Where Condition in a macro using a hidden txt box to produce my results: .

    =[MailingAdd_lbl] Like [Forms]![SearchForm]![txtAddWild]

    I'd like to be able to search a second field to produce a single report showing matching results from BOTH fields

    I've tried the OR operator to no avail... ie:

    =[MailingAdd_lbl] Like [Forms]![SearchForm]![txtAddWild] OR [PhysicalAdd_lbl] Like [Forms]![SearchForm]![txtAddWild]



    I've also tried adding the second expression as a secondary action but it only produces the results from the second expression.

    I also took a stab at inserting VBA code but before killing an hour or two of my afternoon I thought I'd ask the experts.

    Thanks for your input!!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    make 2 queries,
    Q1 searches fld1
    Q2 searches fld2
    put them both together in a union query:
    select * from Q1
    union
    select * from Q2

    in both queries tho, add a Note field to tell you what field found it.
    Q1: select *,"Found in [myfield1]" as Note from table
    Q2: select *,"Found in [myfield2]" as Note from table

    all you do is run the union query
    docmd.openquery qnUnion

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

Similar Threads

  1. Compare Fields Then Produce a MsgBox
    By gameemaster in forum Access
    Replies: 1
    Last Post: 09-28-2016, 04:51 AM
  2. Filtered results without comparison operator
    By Steve_Blackman in forum Access
    Replies: 1
    Last Post: 07-01-2014, 09:36 AM
  3. searching quantity by using operator
    By mathanraj76 in forum Programming
    Replies: 12
    Last Post: 05-31-2013, 01:13 AM
  4. Replies: 17
    Last Post: 09-24-2012, 08:42 AM
  5. Replies: 1
    Last Post: 12-21-2010, 09:27 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