Results 1 to 3 of 3
  1. #1
    sra2786 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Oct 2017
    Location
    Cincinnati, OH
    Posts
    38

    Need Calendar Month to be a key

    I am very new to Access. I need to include Calendar Month (ie, 201710, 201711) as part of a key in a table. There will be two key fields (Calendar Month + State) that make up the key for this table. The rates will change each month and that is why Calendar Month needs to be part of the key.



    Table Examples Format
    Calendar Month 201710, 201711 Text or Number
    State OH, KY Text
    Rate 1.00, 1.32 Currency

    Questions
    1. Should I make Calendar Month a text or numeric field. The Calendar Month will be used to link to data in another table
    2. Is it required to add an "Id" (Autonumber) field

    Thanks.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    If rates will change each month then month and state are not enough for a unique identifier, assuming data will be multi year. Autonumber field is not required, however this could the PK that is saved as FK to related table then set Year, Month, State as compound index to prevent duplicate combinations.
    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.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,936
    you should keep the two fields separate - and each indexed separately. Any query would then the be filtered on the basis of

    yearmonth=12345 and state='OH'

    also store the yearmonth as a numbers use fewer bytes than text so take up less space so indexing will be faster.

    Also means if you want to filter on state then you do not have to split your index - which will be significantly slower with an sort of data volumes.

    I would have a separate ID as autonumber, it is just good practice. If you want to prevent duplicates, you can still set a multi field index on the two fields

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

Similar Threads

  1. Replies: 3
    Last Post: 09-23-2016, 07:25 PM
  2. Calendar picker with month/year only
    By bbmak in forum Forms
    Replies: 1
    Last Post: 01-11-2014, 02:27 PM
  3. sort query results by calendar month
    By sfgiantsdude in forum Access
    Replies: 4
    Last Post: 06-12-2013, 12:12 PM
  4. 30 reward dollars per calendar month.
    By NewMexicoNovice in forum Access
    Replies: 2
    Last Post: 05-31-2013, 05:42 PM
  5. Replies: 5
    Last Post: 08-20-2012, 11:11 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