Transfer spreadsheet data to access - overwrite existing / transfer range instead of looping

I have been shown by Kevin how to push data records from an excel spreadsheet to an access db using VB.

As a follow up to that solution, I now need to know how to overwrite the access data record with the new pushed excel record, if the value in Field1 is already in the access db.

Also, is there a way to push a named range over to the db instead of looping through the sheet and pushing record by record? Goal here is to speed up the macro.

Thanks, B.
BlingoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zorvek (Kevin Jones)ConsultantCommented:
To update an existing record or add a new record if the key does not already exist:

   MyRecordset.MoveFirst
   MyRecordset.Find "Field1='ABC123'"
   If MyRecordset.BOF Or MyRecordset.EOF Then
      MyRecordset.AddNew
   End If
   MyRecordset!Field1 = SourceSheet.Cells(Row, "A")
   MyRecordset!Field2 = SourceSheet.Cells(Row, "B")
   MyRecordset.Update

Other than using the Access DoCmd.TransferSpreadsheet statement I know of no way to bulk load a worksheet into a table with a single statement.

Kevin
zorvek (Kevin Jones)ConsultantCommented:
Found something but don't have time to test it:

Title: Insert records to Access from xl
Link: http://www.ozgrid.com/forum/showthread.php?t=44667

Kevin
BlingoAuthor Commented:
Thanks again Kevin. One more thing - how can I make the value of Field1 dynamic, so it checks all records as it loops through instead of being fixed as ABC123?

Price Your IT Services for Profit

Managed service contracts are great - when they're making you money. Yes, you’re getting paid monthly, but is it actually profitable? Learn to calculate your hourly overhead burden so you can master your IT services pricing strategy.

zorvek (Kevin Jones)ConsultantCommented:
  MyRecordset.Find "Field1='" & SourceSheet.Cells(Row, "A") & "'"

Kevin

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BlingoAuthor Commented:
I've got the whole project working perfectly. You are a legend. One more question... are you a robot? I wasn't aware that humans were capable of response times that can be measured in milliseconds and your responses don't have any trace of human error. You must be some sort of AI.
zorvek (Kevin Jones)ConsultantCommented:
>your responses don't have any trace of human error.

Ha! If only that were really true ;-)

Thank you for the complement...I've added it to my list of accolades: http://www.experts-exchange.com/M_1677072.html

Kevin
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.