Results 1 to 3 of 3

Thread: [RESOLVED] how to create composite primary key in access

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2006
    Posts
    57

    Resolved [RESOLVED] how to create composite primary key in access

    Hai everyone, i have two tables Center and Batch.

    The fields are,

    Center:
    Center_id,Centername

    Batch:
    Batch_id,Batchtiming,Center_id

    The two tables are related by Center_id. In the center table Center_id is the primary key and in Batch table Batch_id is the primary key. I want to combine in Batch_id and Center_id in Batch table since i have multiple entries of Batch_id in the Batch table, which is not allowed when i have only Batch_id as primary key.

    Please help me out. Thank you,

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: how to create composite primary key in access

    Manually...

    Open your Batch table in design view and select the Center_Id row and hold down the shift key and select the batch_id row so they are both highlighted (they need to be contiguous. If there not just drag and drop so they are next ot each other). Then clikc on the primary key toolbar button and viola!
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2006
    Posts
    57

    Re: how to create composite primary key in access

    Hai, i have another table SD3 which has three fields Batch_id,Center_id and Stud_id. I want to reference Batch_id in SD3 to Batch_id in Batch table which is a composite of Batch_id and Center_id. I am not able to referece these two tables with Batch_id, it says "No unique index found for the refereced field of the primary table"

    Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width