Results 1 to 8 of 8
  1. #1
    revnice is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    61

    Locking cus_num to cus_name


    I want a specific number to be associated with a particular customer at all times. If a customer is deleted, the associated number is deleted forever as well.

    I have a little (primary) key symbol against both num and name columns in the cus table (Design View) - which I thought would lock them together, but it doesn't.

    If I sort either column, the wrong number ends up next to the customer name.

    How do I lock them together?

    Thanks - rev

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    If they're in the same table then you can't at the table level. If the number is the primary key for the table (the little key symbol you mentioned) but not the Name field in that table, you will be allowed change the name should you need to but the number will go away when the record is deleted. If that field is an AutoNumber then the number will never be used again. It is the built in Referential Integrety enforcement (if turned on) that helps when there is more than one table involved.

  3. #3
    revnice is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    61
    So I should dump my Access-generated PK and use the cus_num as the PK instead - with data-type AutoNumber and referential integrity turned on?

    Have I got that right?

    BTW: Where do you turn on referential integrity?

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    If you allowed Access to add a Primary key then it *is* an AutoNumber. That is all you need in that table for a PrimaryKey. RI is turned on as you begin defining your relationships, which is why I said more than one table.

  5. #5
    revnice is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    61
    Ok, understood all that but I'm still not clear on how to lock num to name.

    Can't num and name be part of a composite key in the same table? If so, how do you do it?

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Of course, but I'm not real convinced that is what you want to do. That will keep you from changing the Company name which you can enforce in a form if that is what you want to do.

  7. #7
    revnice is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Aug 2010
    Posts
    61
    So how do I make a composite key?

    I only see a button for Primary, nothing for 'secondary.'

    I tried putting the little PK symbol against both columns but as noted, that didn't work.

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    This link should help: http://www.btabdevelopment.com/ts/mfi

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

Similar Threads

  1. Locking form with Visual Basic
    By rev_ollie in forum Forms
    Replies: 4
    Last Post: 04-29-2010, 07:27 AM
  2. Locking Records in Subform
    By MuskokaMad in forum Forms
    Replies: 1
    Last Post: 04-02-2010, 06:34 PM
  3. Multiple valued field locking tables
    By Jamy in forum Programming
    Replies: 6
    Last Post: 02-19-2010, 11:24 AM
  4. locking pathways for attachments
    By highland in forum Access
    Replies: 0
    Last Post: 07-26-2009, 06:37 PM
  5. Access Locking other users out
    By David in forum Access
    Replies: 1
    Last Post: 07-02-2009, 09:26 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