Results 1 to 11 of 11
  1. #1
    smoothlarryhughes is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Sep 2012
    Posts
    36

    Relating similar fields???

    Is it possible to relate tables where the fields are slightly different? For example table 1 has a reference column with AB1300033370A100, table 2 has AB13000333700000, and table 3 has AB1300033370A1A0...I want to relate based on the first 12 digits in each reference, but I will want to be able to see the full reference on my queries.



    Anyone know the best way to go about doing this?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Should be possible. Create the query with a regular join. In SQL view, add the Left() function around the field names in the join.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    smoothlarryhughes is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Sep 2012
    Posts
    36
    Quote Originally Posted by pbaldy View Post
    Should be possible. Create the query with a regular join. In SQL view, add the Left() function around the field names in the join.
    something like this?
    SELECT FROM tbl_tf INNER JOIN tbl_tf_sec_processing ON LEFT(tbl_tf.SENDERREF,12) = LEFT(tbl_tf_sec_processing.REFERENCE,12);

    this gives me an error. incorrect punctuation.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You don't have any fields selected.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    smoothlarryhughes is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Sep 2012
    Posts
    36
    Quote Originally Posted by pbaldy View Post
    You don't have any fields selected.
    THANKS...this seems to work, but the query takes a good 2 - 3 minutes to run and then freezing up the computer pretty much indefinitely....any ideas on a better way this can be done?

  6. #6
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    How many records in your tables? You are performing the left function for every record which could account for some of the time.

    Is this a one time thing or recurring?

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Yeah, it has to apply the function to every record in both tables, and probably can't use indexes, so it won't be fast. This might be a situation where saving that value in the tables would make sense.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    smoothlarryhughes is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Sep 2012
    Posts
    36
    Is there any easy way to append the new data when I am importing it into the table? I would like to keep the column with the full references and just have another column added to cut off the last 4 digits.

  9. #9
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Yes you can do that. For each table involved:
    Create the new field, populate it with an update query. I would index the new field.
    Then create a query where you join on the new fields.

    A little time in the set up, but it should run very fast.

    Good luck.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You can probably do it during import too, depending on your method.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    smoothlarryhughes is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Sep 2012
    Posts
    36
    Do you have any info on how to do it on import? Could I do it via a macro?

    Thanks for your help

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

Similar Threads

  1. Replies: 5
    Last Post: 07-14-2019, 05:22 PM
  2. relating fields from one table to a form
    By ljmellor in forum Forms
    Replies: 11
    Last Post: 12-06-2012, 03:55 PM
  3. Replies: 2
    Last Post: 05-29-2012, 07:13 PM
  4. Database design- need help relating fields
    By sebeckett in forum Access
    Replies: 5
    Last Post: 09-02-2011, 02:21 PM
  5. Replies: 1
    Last Post: 11-11-2010, 11:00 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