Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    prestopr66 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    11

    Concatenation of five fields and use to build relationship

    Hello



    I have recently made the jump from Excel to Access. I'm in the process of converting my Excel Spreadsheet (The Monster) to Access. I have built the tables and now establishing relationships!

    The problem I have relates to two tables.
    Table 1. Contains fields that build a unique name for an item from five fields.
    Table 2. Contains multiple bookings against an item (five fields) in table 1.

    However, I may have unnecessarily complicated the relationship as I need to add underscores between each concatenated field in table 1 for ease of viewing and deciphering by the user. But as soon as i do this it presents problems with establishing relationships!

    Is the concatenation of fields without underscore relevant and placement of underscores more relevant for forms and reporting?

    any assistance is appreciated

  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
    I think the rule of thumb would be that table 1 would contain an autonumber primary key field. That field would be stored in table 2 and be used to relate the tables, not the 5 fields (or a concatenation of them). You can present the 5 fields to the user any way you want, but I wouldn't relate tables with them.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,535
    Why not just have an Auto-number field as the primary key for table 1 which would simplify the relationship issue.
    You can still make the records unique using the five other fields.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    prestopr66 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    11
    Thanks Bob
    I have set the primary key as auto-number. But, how do I make the records unique using the five fields?

  5. #5
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,535
    Quote Originally Posted by prestopr66 View Post
    Thanks Bob
    I have set the primary key as auto-number. But, how do I make the records unique using the five fields?
    Take a look at these links:

    https://support.microsoft.com/en-us/...0index%20name.

    https://stackoverflow.com/questions/...cess-databases

    For more try google: access multi field index
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  6. #6
    prestopr66 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    11
    Hi Bob
    Issue sorted! But I arrive back at the same place. How to establish a relationship between two tables;
    Table 1. Field GCOB_ID (concatenation of five fields)
    Table 2. Field PROD_GCOB_ID
    Maybe I'm missing the fundamentals here!!

  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
    As I mentioned in post 2, you would save the autonumber from table 1 in table 2, not the concatenated field. The relationship would be on that field.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    prestopr66 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    11
    Hi Paul
    i understand that would form the relationship but to the user the auto number would mean nothing! I’m must be missing something.

  9. #9
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    PMFJI but Paul appears to be offline.
    End users should never work directly with tables or queries.
    All interaction should be done via forms.
    Create a query joining the two tables using the common field discussed earlier in the thread and use that query as the record source for the form
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  10. #10
    prestopr66 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    11
    Thanks Isladogs
    All good. But how do I create a concatenated field in the form? The auto-number will mean nothing to the user.
    thanks

  11. #11
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  12. #12
    prestopr66 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    11
    Hi Isladogs
    Just to clarify "Create a query joining the two tables using the common field discussed earlier in the thread and use that query as the record source for the form" I assume I have to create a table based on this query and then use it to build the form?

  13. #13
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    No. Do not create another table.
    As stated create a query joining both tables and add whichever fields you need to your query including your concatenated field.
    The query forms the record source for the form.
    There is no reason to display the autonumber field unless you want to ...as it has no meaning other than being a unique identifier
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  14. #14
    prestopr66 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    11
    Thanks
    OK, but something is not right. When I create the form the query is not listed to select. I also notice that the query icon itself has an exclamation mark. What does that mean??
    Your help is appreciated

  15. #15
    prestopr66 is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    11
    Ignore the last post!!!

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 04-18-2018, 03:38 PM
  2. Replies: 5
    Last Post: 05-03-2014, 02:03 PM
  3. Replies: 4
    Last Post: 04-01-2014, 02:11 PM
  4. Concatenation of Access Fields.
    By congamond in forum Access
    Replies: 1
    Last Post: 01-30-2014, 07:13 PM
  5. Build a relationship between Queries (Howto)
    By Access_Headaches in forum Queries
    Replies: 1
    Last Post: 06-24-2010, 01:41 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