database - MS Access 2010: Deleting duplicates without primary key -


i working client gets data in excel spreadsheets wants import data access table. fields data records are:

-invoicenum -invoicedate -customer -shipdate -quantity -item -priceeach

he receives data twice per month, , each time receives data, wants able import data table in access.

there 2 issues causing me problem: 1) there no primary key data (the closest field primary key "invoicenum", unfortunately multiple records can have same string field); 2) duplicate records possible, "duplicate records" mean 2 records have same values each field.

the problem not want duplicate records in data table.

i don't know best way handle this. hoping suggestions concerning following:

a) should store records in excel spreadsheet linked access table? thinking if this, can append each new set of data spreadsheet (including duplicates), write macro in excel remove duplicates (i noticed can using "remove duplicates" command on "data" tab).

or

b) should store data directly in access table? can write vba program or macro import each new set of excel data access table, there way importing can eliminate duplicates (again, there no primary key in table)?

or

c) there option better other 2 above?

thanks this! appreciate it!

if can't @catcall suggests (i.e., fix process produces dupes), i'd way:

  • create staging table in access. it's function buffer table each import, , cleared after use.

  • import using method @hansup provided (i.e., sql string connect string in in clause).

  • then use query left join existing invoices find ones new:

      select tblbuffer.invoicenum, tblbuffer.invoicedate, tblbuffer.customer, tblbuffer.shipdate, tblbuffer.quantity, tblbuffer.item, tblbuffer.priceeach        tblbuffer left join tblinvoices          on tblbuffer.invoicenum = tblinvoices.invoicenum       tblinvoices.invoicenum null

that give new invoices, , can turn insert command insert records:

       insert tblinvoices (invoicenum, invoicedate, customer, shipdate, quantity, item, priceeach)       select tblbuffer.invoicenum, tblbuffer.invoicedate, tblbuffer.customer, tblbuffer.shipdate, tblbuffer.quantity, tblbuffer.item, tblbuffer.priceeach       tblbuffer left join tblinvoices          on tblbuffer.invoicenum = tblinvoices.invoicenum       tblinvoices.invoicenum null
  • now, occur me given field names reason there many duplicate invoices because denormalized data, , cases there's more 1 record invoice more 1 invoice item. in case, may need create invoice header table , insert invoice items invoice details table. i'll leave exercise reader, since it's work mock in abstract when may not matter.

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -