Dear Experts,

i am uploading data from excel using below code.

now i want to do overwrite on existing data in access table.

what should i do? how can i get.

Public Sub DoExcelImport()
' Excel object variables
Dim appExcel As Excel.Application
Dim wbk As Excel.Workbook
Dim wks As Excel.Worksheet
'*********Leave ReocardSet
Dim LeaveRec As Recordset, dbs As Database
Dim rs2 As New ADODB.Recordset, IDFind As String
Dim cnn2 As New ADODB.Connection
Dim cmd2 As New ADODB.Command, SourceRange As String

SourceFile = CurrentProject.Path & "\Leave1.xlsx"

Set rsCon = CreateObject("ADODB.Connection")

With cnn2
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & SourceFile & ";Extended Properties=""" & "Excel 12.0 Xml;HDR=YES;IMEX=1;" & """"
End With
Set cmd2.ActiveConnection = cnn2
cmd2.CommandType = adCmdText
cmd2.CommandText = "SELECT * FROM [Sheet1$]"

rs2.CursorType = adOpenStatic

rs2.Open cmd2

Set dbs = DBEngine(0)(0)
Set LeaveRec = dbs.OpenRecordset("Leave", dbOpenTable)

For i = 1 To rs2.RecordCount
With LeaveRec
.Fields(0) = rs2.Fields(0)
.Fields(1) = rs2.Fields(1)
.Fields(2) = rs2.Fields(2)
.Fields(3) = rs2.Fields(3)

End With

Set wks = Nothing
Set appExcel = Nothing
Exit Sub
MsgBox Err.Description, vbOKOnly, Err.Source & ":" & Err.Number
Resume doExcelAutomationExit
End Sub