ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   work with ADO or DAO (https://www.excelbanter.com/excel-programming/336764-work-ado-dao.html)

walker002[_2_]

work with ADO or DAO
 

Hi,

I would like to realize with Excel by DAO or ADO two things:
The available tables of Excel should be updated by the tables i
Access.
Best of all simply overwrite.

Per table:
Either an available line should be updated by changes in Excel i
Access, or a new line be added.

More should not happen, actually. I hope that there is for this an eas
and quick solution.
Unfortunately, I cannot handle yet with ADO or DAO.
What is better ?

Who could help me there?

Many thanks already beforehand
Walke

--
walker00
-----------------------------------------------------------------------
walker002's Profile: http://www.excelforum.com/member.php...fo&userid=2591
View this thread: http://www.excelforum.com/showthread.php?threadid=39413


Jean-Yves[_2_]

work with ADO or DAO
 
Hi Walker,

With ADO, You can test the following. Supposing you have Payroll in col A,
named myrange and Status in column B

'First make a reference via Tool/References .... To Microsoft ActiveX Data
Objects 2.x

Sub test()
Dim connMdb As ADODB.Connection
Dim recMdb As ADODB.Recordset
Dim strStatus As String

Set connMdb = New ADODB.Connection
Set recMdb = New ADODB.Recordset
"open a connection to the DB
connMdb.Open "Provider= Microsoft.Jet.OLEDB.4.0;" & "Data Source = " &
ThisWorkbook.Path & "\myDB.mdb;"

For Each cl In Range("MyRange")
'open the recordset corresponding to the payroll
recMdb.Open "Select Payroll, Status from STAFF ;", connMdb,
adOpenForwardOnly, adLockOptimistic
If recMdb.EOF = False Then
strStatus = recMdb.Fields("Status").Value
If cl.Offset(0, 1) < strStatus Then Debug.Print
recMdb.Fields("Payroll").Value & " " & recMdb.Fields("Status").Value
recMdb
Else : debug.print " No data for " & cl.value
End If
recMdb.Close
Next cl

connMdb.Close
Set recMdb = Nothing
Set connMdb = Nothing
End Sub

Regards

Jean-Yves

"walker002" wrote
in message ...

Hi,

I would like to realize with Excel by DAO or ADO two things:
The available tables of Excel should be updated by the tables in
Access.
Best of all simply overwrite.

Per table:
Either an available line should be updated by changes in Excel in
Access, or a new line be added.

More should not happen, actually. I hope that there is for this an easy
and quick solution.
Unfortunately, I cannot handle yet with ADO or DAO.
What is better ?

Who could help me there?

Many thanks already beforehand
Walker


--
walker002
------------------------------------------------------------------------
walker002's Profile:

http://www.excelforum.com/member.php...o&userid=25917
View this thread: http://www.excelforum.com/showthread...hreadid=394137





All times are GMT +1. The time now is 07:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com