View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
leung leung is offline
external usenet poster
 
Posts: 119
Default Data From Excel Range To Existing Access Table

Hi

your code works great and I have modified a little bit so make it once
insert it to Access, it will then be deleted and looks like it is "moved" to
Access. However,

I have 2 problems he
1. the first field i have in the DB is an autonumber field, how can I handle
it ? if I put an empty value, it will prompt error

2. the process seems a little slow, it seems using loop from row to row
quite slow.

thanks a lot

Leung


"michelxld" wrote:


Hello

I hope this help you

Sub exportDatas_Excel_Access()
'Activate Microsoft ActiveX Data Objects x.x Library
Dim Conn As New ADODB.Connection
Dim rsT As New ADODB.Recordset
Dim Cell As Range
Dim i As Integer

With Conn
.Provider = "Microsoft.JET.OLEDB.4.0"
.Open "C:\dataBase.mdb"
End With

With rsT
.ActiveConnection = Conn
.Open "Table1", LockType:=adLockOptimistic
End With

'export range("C1:C4") in Access table
With rsT
.AddNew
For i = 0 To 3
.Fields(i).Value = Cells(i + 1, 3)
Next i
.Update
End With

rsT.Close
Conn.Close
End Sub


Regards ,
michel


--
michelxld
------------------------------------------------------------------------
michelxld's Profile: http://www.excelforum.com/member.php...o&userid=17367
View this thread: http://www.excelforum.com/showthread...hreadid=392393