473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to Import only new records from excel

Hi, I have a macro that combines many worksheets into one and after I need this worksheet to update a Table in Access but only with newly generated records. I have linked the combined worksheet to the Access DB as a table though the table I want to update is different which contains previously generated records. Any ideas, especially if I can add the code to the existing macro or a query that runs when i open the DB.
Oct 15 '09 #1
6 8216
ADezii
8,834 Expert 8TB
@kinuthia54
On little trick that I use when transferring limited information/data between Excel and Access is to use the System Registry for the transference since they will Save and Retrieve data from the same Key using SaveSetting and GetSetting(). A simple example below will illustrate this point:
  • In Execl, save the First ID of the newly Added Record:
    Expand|Select|Wrap|Line Numbers
    1. SaveSetting appname:="MASTER Worksheet", Section:="Data Merge", _
    2.             Key:="First ID", setting:=1000000
  • In Access, retrieve the ID of the first newly Added Record:
    Expand|Select|Wrap|Line Numbers
    1. Dim lngFirstRecID As Long
    2.  
    3. lngFirstRecID = GetSetting(appname:="MASTER Worksheet", Section:="Data Merge", _
    4.                           Key:="First ID", Default:="999999")
    5.  
    6. If lngFirstRecID = 999999 Then
    7.   MsgBox "No First Record ID stored"
    8. Else
    9.   MsgBox "First ID of Newly Added Record: " & lngFirstRecID
    10. End If
Oct 15 '09 #2
Thanks Adezii,

The only issue I have is its hard to tell which is the first newly added record, since this main excel sheet is re consituted by combining many other worksheets around 2000 of them which contain the changes. The only comparison i have is with the Access table that has the earlier records. hence I need something to compare the old access table and the excel sheet and only pick what isnt in the access table to import.

Thanks
Oct 15 '09 #3
FishVal
2,653 Expert 2GB
If you set a unique index to the Access table field (or multifield index for several fields) which is supposed to be unique per record, then database engine automatically omit adding records already present in your table.
Oct 15 '09 #4
NeoPa
32,556 Expert Mod 16PB
If you have the worksheet linked as a pseudo-table in Access (I think you have), then you can design a query which includes both tables with a Type-2 connection between the Unique-ID fields and filter out all those records except where the destination key is Null. That will copy only the non-existent records by design and will run more efficiently than copying all and relying on the existing ones to fail.
Oct 15 '09 #5
Thank you so much this will solve my issue
Oct 16 '09 #6
NeoPa
32,556 Expert Mod 16PB
Good for you, and we're pleased to have helped.

Welcome to Bytes!
Oct 16 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Elaksomfan | last post by:
Hi, I am having trouble importing data from an excel spreadsheet into MS SQL Server 2000 using DTS Wizard. The DTS import process is successfull, no errors, but only 50 rows of approx. 1500 rows...
5
by: Johnny Meredith | last post by:
I have seven huge fixed width text file that I need to import to Access. They contain headers, subtotals, etc. that are not needed. There is also some corrupt data that we know about and can...
4
by: Steve Jorgensen | last post by:
I'm restarting this thread with a different focus. The project I'm working on now id coming along and will be made to work, and it's too late to start over with a new strategy. Still, I'm not...
1
by: John Hewitt | last post by:
A 'newbie' question - importing into Access from Excel. Googled the group postings but I can't find the amswer I have a 50 line three column file in Excel that contains Names and Tel numbers....
1
by: richardkreidl | last post by:
I have many *.txt files in a folder. I need to loop through the folder and open every .txt file and import the records into an Excel worksheet. The records for all the text files are in the...
1
by: baling | last post by:
Hi.... Hi everybody, i have a code that i make in VBA and know I want to use this code in to VB6. But i don't know how to use that code in to VB 6.0 Please correct this code so i can use it in VB...
2
by: Quique | last post by:
Hello, I've got a problem importing a worksheet Excel into a temporary table in access. All the information is imported but the table is not ordered as it is originally in excel. I'm using a...
2
by: ontherun | last post by:
Hi, Could anyone please assist me on how to import Excel records to Access. the records in excel are not in the same order as that of the one in Access. there are about 1000 records needs to be...
0
by: RazSam | last post by:
Hi I am developing in c# .net 2,0 web forms and having some problems. Code is attached below. I have written code to export the contents of a Grid View to Excel, this works. The problem occurs...
5
by: Bill Schanks | last post by:
I have a winform app (VB 2005) that allows users to export data to excel, make updates to the excel file and import the data from that Excel file and update the database. My question is: Is it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.