Results 1 to 6 of 6
  1. #1
    acrowe97 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Aug 2018
    Posts
    41

    Query covering 2 fields

    The query I'm making is going to be used in a report, showing what company has what keys related to a specific office suite. The issue is some companies use a doing business as (DBA) title instead of the company name on the lease. I need to have the query look up partial names of either the company or DBA name so the data displays. Any suggestions?

  2. #2
    acrowe97 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Aug 2018
    Posts
    41
    I tried using the Like * & " " & * search in both the Company field and DBA field at the same time but it just gives me two search boxes and no data is displayed on the query.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,728

  4. #4
    acrowe97 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Aug 2018
    Posts
    41
    SELECT Tenants.CompanyName, Tenants.DBA, Suites.SuiteNumber, [Suite Key List].KeyNumber, [Suite Key List].Quantity, [Suite Key List].Notes, [Suite Key List].MapKeyAtt, [Suite Key List].Security, [Suite Key List].SecurityCodeON, [Suite Key List].SecurityCodeOFF
    FROM Tenants INNER JOIN ((Leases INNER JOIN Suites ON Leases.LeaseID = Suites.LeaseID) INNER JOIN [Suite Key List] ON Suites.SuiteNumber = [Suite Key List].SuiteNumber) ON Tenants.TenantID = Leases.TenantID
    WHERE (((Tenants.CompanyName) Like "*" & [Enter a tenant/company:] & "*"));

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,728
    You could try this query just to see if you get back the data/records you expect.
    Code:
    PARAMETERS pSearchName text(20);
    
    SELECT Tenants.CompanyName
        ,Tenants.DBA
        ,Suites.SuiteNumber
        ,[Suite Key List].KeyNumber
        ,[Suite Key List].Quantity
        ,[Suite Key List].Notes
        ,[Suite Key List].MapKeyAtt
        ,[Suite Key List].Security
        ,[Suite Key List].SecurityCodeON
        ,[Suite Key List].SecurityCodeOFF
    FROM Tenants
    INNER JOIN (
        (
            Leases INNER JOIN Suites ON Leases.LeaseID = Suites.LeaseID
            ) INNER JOIN [Suite Key List] ON Suites.SuiteNumber = [Suite Key List].SuiteNumber
        ) ON Tenants.TenantID = Leases.TenantID
    WHERE (Tenants.CompanyName LIKE "*" & pSearchName & "*")
        OR (Tenants.DBA LIKE "*" & pSearchName & "*");

  6. #6
    acrowe97 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Aug 2018
    Posts
    41
    It works!! Thank you so much.

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

Similar Threads

  1. Replies: 2
    Last Post: 11-27-2017, 08:59 PM
  2. Replies: 2
    Last Post: 04-11-2016, 03:54 PM
  3. Replies: 4
    Last Post: 07-17-2013, 01:11 PM
  4. Replies: 12
    Last Post: 05-07-2012, 12:41 PM
  5. Replies: 0
    Last Post: 12-12-2009, 04:45 PM

Tags for this Thread

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