Results 1 to 6 of 6
  1. #1
    roybb is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2014
    Posts
    5

    Related Tables

    Hi Everyone,

    I'm fairly new to access. What I am trying to do is create a database for keeping track of minutes remaining on support contracts (for example a customer initially purchased 90 minutes of support and then used 15 minutes of that contract).

    I want to have 2 tables.

    The first one is a general view of the individual customers and will include:
    - Customer No (AutoNumber)
    - Last Name
    - First Name
    - If they have an active contract
    - Time remaining on their current contract and the date their last contract was purchased

    The second table will be a log of the individual sessions for each customer and will include:
    - Customer No
    - Date
    - Duration of contracted "used up"
    - Description

    I have made Customer No in the first table a primary key and made it a foreign key in the second table (one to many).

    I am having trouble setting up the second table so that I can log multiple sessions for the same Customer No (due to Customer No being an AutoNumber). What I would ultimately like to do with the second table is to be able to print out a list with a log of an individual customer's sessions.



    I am really not sure how to approach this?

    Thanks!

    Roy

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    In the second table, "Customer No" should be a Long, not an Autonumber.


    This is how I would begin. I see 3 tables:
    Code:
    Table:  Customers
    ----------------
    CustomerID_PK   Autonumber
    CustomerNum     Text (optional - user assigned)
    FirstName       Text
    LastName        Text
    'Other customer data: Address, cellPh, Email, etc
    
    
    Table: Contracts
    ----------------
    ContractID_PK   Autonumber
    CustomerID_FK   Long
    EventTypeID_FK    Long  
    EventDate       Date/Time
    Amount          Long (if using only whole minutes)
    Description     Text (or Memo)
    
    
    Table: EventType
    ----------------
    EventTypeID_PK    Autonumber
    Description     Text
    To begin with, the EventType table entries would be "Purchased" and "Used".
    "Purchased" would be a positive number and "Used" would be negative. Adding the "Purchased" and "Used" would give total minutes left.
    You could use the EventDate field to see a running history of "Purchased" and "Used" time.
    Other events could also be added: "Voided", "Adjustments", "Refund".

    The fields with the suffix "_PK" or "_FK" should never be displayed on a for/report. They are to provide a unique record identifier and for linking purposes.


    Hopefully, others with more design experience will chime in.



    You might want to see these tutorials:
    http://www.rogersaccesslibrary.com/forum/forum46.html

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    This is like inventory tracking. Sum total purchased minus Sum total used = balance.

    Review: http://allenbrowne.com/AppInventory.html

    Look at the Microsoft Desktop Product Inventory database template for ideas.

    I expect you will need more than 2 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.

  4. #4
    roybb is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2014
    Posts
    5
    Hi,

    Thank you for your reply!

    I definitely see why the CustomerID_FK in the second table needs to be a Long but I am unable to change it from AutoNumber as FM gives me a warning that I can not change the type because of the relationship it has with the other table.

    Can anyone shine some light on this??

    Thanks!

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Just changing the type won't be useful. Need a new field for the customer ID foreign key. Then need to populate that field with the CustomerID value from Customers table.

    Can you just delete records from second table and start over?

    Then remove relationships from Relationship window. Create the new field, delete the old autonumber field. Reset relationship with the new FK field.
    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.

  6. #6
    roybb is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2014
    Posts
    5
    I got it figured out, thanks so much!

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

Similar Threads

  1. Replies: 5
    Last Post: 12-14-2012, 04:21 PM
  2. One Form to Update 2 Related Tables?
    By zannix in forum Forms
    Replies: 3
    Last Post: 01-26-2012, 08:46 AM
  3. Query on related tables question
    By jpkeller55 in forum Access
    Replies: 12
    Last Post: 09-28-2010, 07:18 PM
  4. Query with related tables question
    By jpkeller55 in forum Access
    Replies: 4
    Last Post: 09-25-2010, 04:29 AM
  5. 3 Related Dependent Tables
    By jbarrum in forum Access
    Replies: 0
    Last Post: 11-17-2009, 11:27 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