Import Excel Data to Access Table - Retain Primary Keys

chrisk1979

New Member
Joined
Aug 8, 2019
Messages
1
I am working on an inventory database in Access. I have a build of materials list in Excel. The part numbers have prefixes, bases and suffixes. Some of the part numbers are on the build of materials multiple times. Some of the part numbers change occasionally (suffix only; prefix and base will always stay the same). The changes happen often enough (not only part suffix changes, but parts being added, deleted or moved around) that I want to automate the import process of the parts on this build of materials on a daily basis to make sure I keep up with all changes automatically.

In Access, I am going to be keeping track of stock levels, invoicing, receiving new quantities, etc. - all kinds of activity which requires these parts to have a static primary key because I need to retain history and accurate stock levels of each part.

How can I import this data from Excel into Access on a regular basis and have Access:
1) Append any new parts (add to the end)
2) Ignore any existing parts that haven't changed at all
3) Replace or update part number (suffix) on those that have changed suffixes and retain its primary key, and therefore all its history, etc.

AND I also only want every part on the build of materials in my Access table only ONCE regardless of how many times it appears on the build of materials Excel file - I don't want more than one instance of a part number with a different primary key for each.

Please let me know if anyone can help or if any more clarification is needed.

Thanks!
 

123DavidRhodes

New Member
Joined
Aug 8, 2019
Messages
8
I am working on an inventory database in Access. I have a build of materials list in Excel. The part numbers have prefixes, bases and suffixes. Some of the part numbers are on the build of materials multiple times. Some of the part numbers change occasionally (suffix only; prefix and base will always stay the same). The changes happen often enough (not only part suffix changes, but parts being added, deleted or moved around) that I want to automate the import process of the parts on this build of materials on a daily basis to make sure I keep up with all changes automatically.

In Access, I am going to be keeping track of stock levels, invoicing, receiving new quantities, etc. - all kinds of activity which requires these parts to have a static primary key because I need to retain history and accurate stock levels of each part.

How can I import this data from Excel into Access on a regular basis and have Access:
1) Append any new parts (add to the end)
2) Ignore any existing parts that haven't changed at all
3) Replace or update part number (suffix) on those that have changed suffixes and retain its primary key, and therefore all its history, etc.

AND I also only want every part on the build of materials in my Access table only ONCE regardless of how many times it appears on the build of materials Excel file - I don't want more than one instance of a part number with a different primary key for each.

Please let me know if anyone can help or if any more clarification is needed.

Thanks!

Hello,
Based on the dynamic nature of the excel file, if it were me I would link the excel file in Access. Any changes to the excel file will be realized in real time in the access table. Go here to learn how to link your excel file.
https://support.office.com/en-gb/article/import-or-link-to-data-in-an-excel-workbook-a1952878-7c58-47b1-893d-e084913cc958

Search: Link to data in Excel on the web page
 

xenou

MrExcel MVP, Moderator
Joined
Mar 2, 2007
Messages
16,551
Office Version
2013
Platform
Windows
If prefix + base doesn't change then just make that the primary key.

Although off the record I do wonder what problems may show up down the road if you are ignoring or otherwise updating suffixes. Don't they have some purpose?
 
Last edited:

Forum statistics

Threads
1,081,622
Messages
5,360,079
Members
400,569
Latest member
tcormack

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top