ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I, in a marco VBA, code to take data from excel and append it to Access? (https://www.excelbanter.com/excel-programming/344489-how-do-i-marco-vba-code-take-data-excel-append-access.html)

Pete[_24_]

How do I, in a marco VBA, code to take data from excel and append it to Access?
 
I would like to appended my excel data to a access database table. I
can manualy do this but I need to programmatly do it. I also must
avoid the message "you are about to append ??? records".
Thanks for your help.


David Lloyd[_3_]

How do I, in a marco VBA, code to take data from excel and append it to Access?
 
Pete:

One alternative is to use the QueryDef class of DAO. For example:

Function RunAppendQuery()
Dim qdf As QueryDef

Set qdf = CurrentDb.QueryDefs("MyAppendQuery")
qdf.Execute

Set qdf = Nothing

End Function

The example assumes that you have saved your append query in Access and that
you have linked your Excel workbook into Access. You could tie this
function to the click event of a command button, for instance. You will
need a reference to the Microsoft DAO library, of course.

Information on creating an Append query can be found in the following KB
article (if needed).

http://support.microsoft.com/default...b;en-us;306093


--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


"Pete" wrote in message
oups.com...
I would like to appended my excel data to a access database table. I
can manualy do this but I need to programmatly do it. I also must
avoid the message "you are about to append ??? records".
Thanks for your help.




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

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