Results 1 to 7 of 7
  1. #1
    plyd is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    3

    combine 2 fileds to make a primary key field using formulas (not SQL programing)


    I am a new Access user and not quite up with SQL programming yet. I am trying to combine 2 fields (Build and Unit) into 1 and make that my primary key field. I was hoping to use a formula similar to that in EXCEL but cant find anyway to do this - can someone guide a novice through this (Access2010)?

    Thanks
    Plyd

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,738
    The best advice I can suggest is to read the first 3 topics and the Hernandez process at this site.
    http://www.rogersaccesslibrary.com/forum/topic238.html


    Table structure and design are important as you are learning Access. And note Access is NOT Excel.
    You could use Access and its interfaces for a lot of things before becoming proficient in SQL.

    Good luck

  3. #3
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    its pretty simple to concantenate two fields during user data input; i.e. presuming you have 3 fields in the table and form: Build, Unit, KeyBU

    then in the AfterUpdate Event of Build & Unit you put:
    me.KeyBU=Me.Build&Me.Unit

    you have to put that code in both because the human could change the data in either at any time; which brings up the issue that in my experience it is better to have the key as an autonumber not seen by anyone. humans are error prone - - and one way or another will screw things up.... perhaps I'm a bit cynical in my old age....

    hope it helps.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,738
    I agree with NTC that auto number as a PK is great. I would set up a field ID as autonumber, and make it the PK. If you want to have an index on BUILD & UNIT, say KeyBU as NTC suggested, then make a unique index on that combination of fields. That will prevent duplicates in your data. (when making that unique index use Ignore Nulls = No.)

  5. #5
    plyd is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    3

    Thank You

    This is a big help!!! I am already looking at some of these references

    Thanks!!

    Plyd






    Quote Originally Posted by orange View Post
    The best advice I can suggest is to read the first 3 topics and the Hernandez process at this site.
    http://www.rogersaccesslibrary.com/forum/topic238.html


    Table structure and design are important as you are learning Access. And note Access is NOT Excel.
    You could use Access and its interfaces for a lot of things before becoming proficient in SQL.

    Good luck

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,738
    Great stuff! Keep at it!

  7. #7
    plyd is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    3

    Thank You

    thank you for this i will try to find the after update event and put this in.

    this is a great help thank you



    Quote Originally Posted by NTC View Post
    its pretty simple to concantenate two fields during user data input; i.e. presuming you have 3 fields in the table and form: Build, Unit, KeyBU

    then in the AfterUpdate Event of Build & Unit you put:
    me.KeyBU=Me.Build&Me.Unit

    you have to put that code in both because the human could change the data in either at any time; which brings up the issue that in my experience it is better to have the key as an autonumber not seen by anyone. humans are error prone - - and one way or another will screw things up.... perhaps I'm a bit cynical in my old age....

    hope it helps.

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

Similar Threads

  1. Replies: 1
    Last Post: 10-10-2010, 05:30 AM
  2. Replies: 1
    Last Post: 09-29-2010, 08:01 AM
  3. Combine 2 Fields to make a hyperlink
    By ahightower in forum Forms
    Replies: 2
    Last Post: 06-30-2010, 08:59 PM
  4. Combine one item fields in one field
    By romadm in forum Reports
    Replies: 7
    Last Post: 06-04-2010, 11:09 PM
  5. Help Needed Programing Two boxes!
    By stu_C in forum Programming
    Replies: 3
    Last Post: 03-22-2010, 10:06 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