Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Access export | Excel Discussion (Misc queries) | |||
Export from Access | Excel Discussion (Misc queries) | |||
Export from Access | Excel Discussion (Misc queries) | |||
export access to excel. change access & update excel at same time | Excel Discussion (Misc queries) | |||
Export Worksheet to Access | Excel Programming |