LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Export UNIQUE rows to access with ADO


So Im using the following method to export Excel records directly into
an Access database, where "FileID" is a primary key in the Database
table Im exporting to...


Code:
--------------------
Private Sub ExportMPM_Milestone(db)
Dim rs As Recordset, r As Long
Const strTableName As String = "tblMPM_Milestone"
Set rs = db.OpenRecordset(strTableName, dbOpenTable)
' get all records in a table
r = 2 ' the start row in the worksheet
Do While Len(Range("C" & r).Formula) 0
' repeat until first empty cell in column A
With rs
.AddNew ' create a new record
' add values to each field in the record
.Fields("FileID") = Range("C" & r).Value
.Fields("WPID") = Range("B" & r).Value
.Fields("Name") = Left(Range("D" & r).Value, 40)
.Update ' stores the new record
End With
r = r + 1 ' next row
Loop
rs.Close
Set rs = Nothing
End Sub
--------------------



...the problem is, there are a few duplicate records for the FileID and
I want to only export the rows whose FileID (Column "C") is unique.

Ive found excel formulas on how to indentify unique records, but I
havent been able to figure out how to convert them to VBA code. Ive
also found VBA code to delete duplicate records, but I dont want to
modify the excel worksheet.

Any suggestions on the best / easiest way to do this?


Also, if its easy to do, I would like to keep track of each FileID
which is not imported because it is a duplicate so I can display a
message after the import is complete to the user of what records were
skipped.

Thanks a ton in advance!


--
durex
------------------------------------------------------------------------
durex's Profile: http://www.excelforum.com/member.php...o&userid=27857
View this thread: http://www.excelforum.com/showthread...hreadid=476536

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access export [email protected] Excel Discussion (Misc queries) 0 February 9th 09 02:16 PM
Export from Access jhrBanker Excel Discussion (Misc queries) 1 August 7th 07 09:06 PM
Export from Access tamxwell Excel Discussion (Misc queries) 0 June 28th 05 06:41 PM
export access to excel. change access & update excel at same time fastcar Excel Discussion (Misc queries) 0 June 24th 05 09:27 PM
Export Worksheet to Access R. Choate Excel Programming 2 August 10th 03 01:13 AM


All times are GMT +1. The time now is 08:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"