Results 1 to 8 of 8
  1. #1
    jjmclell is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2015
    Posts
    11

    Query based on two unrelated tables

    I have a table (Table1) that has a text field where users can enter free-form text. Some of the info that they'll invariably enter contains words that match records in an unrelated table (Table2).

    Is there anyway I can query records in Table1 where there is text in the aforementioned text field that matches records in Table2?

    For example, if the field in Table1 contains a record "Bruce gave Carol $25", and a field in Table2 contains "Bruce" as one of its records, can I query out that record in Table1 based on the records in Table2?

    Furthermore, if "Bruce", "John", and "Mary" all belonged to a group called "Sales" in a related table, could I query Table1 to pull out records where any name from the "Sales" group is mentioned in the text field in Table1?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You want to use Keys to create a relationship between your tables. You will want a Primary Keys in your tables. Also, include Foreign Keys to create a relationship from one table to another.
    https://www.youtube.com/watch?v=_aN-8kszIdA

  3. #3
    jjmclell is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2015
    Posts
    11
    I can't have a relationship between the tables. It would never align. It's like having a table where in any given record someone might mention multiple people's names along with a slew of other text (like a description field) and then trying to have a one-to-many relationship with a table of names.

    What I want to do be able to do is go thru records in the table with the free-form text field looking for records where the free-form text field is like *Bruce* or *Mary* or whatever, but have Access check for any name that is in an unrelated table of nothing but names.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Perhaps what you want to do is employ a search form technique. Maybe this will provide some ideas.
    http://allenbrowne.com/ser-62.html

  5. #5
    jjmclell is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2015
    Posts
    11
    I figured it out. I first created a query that showed all the records in Table1 x all the records in Table2. I then queried that query to show only records where data from [FieldX] (originally from Table1) contains the name in the corresponding record data from [FieldY] - in the criteria cell of the queries design view for [FieldX]: [FieldX] = "*" & [FieldY] & "*".

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Glad to hear you found a solution and thanks for posting your solution here.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    That is a Cartesian relation of two tables.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    jjmclell,

    Just for reference you may want to work through this tutorial that will help you with relational database design concepts. It has a structured methodology and it has a solution, but you have to work through it.

    You can work with unrelated tables, but you don't need a relational database to do that.

    Good luck with your project.

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

Similar Threads

  1. Two Unrelated Tables and Have to Add together
    By yamalady in forum Queries
    Replies: 3
    Last Post: 11-22-2013, 09:19 AM
  2. Append query using two unrelated tables
    By maggiemago3 in forum Access
    Replies: 1
    Last Post: 09-07-2013, 09:55 PM
  3. two unrelated tables and parameter query
    By Seito in forum Queries
    Replies: 2
    Last Post: 09-12-2011, 03:01 PM
  4. Combine two unrelated tables with the same fields
    By lghovden06 in forum Queries
    Replies: 4
    Last Post: 07-27-2010, 03:36 PM
  5. Replies: 1
    Last Post: 07-07-2009, 01:00 PM

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