View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Adrian T[_4_] Adrian T[_4_] is offline
external usenet poster
 
Posts: 17
Default Store Data in Access

Hello,

I have the following code that pulls data directly from a sql server into a
spreadsheet. Now, I'd like to modify the code so I can store the data into an
Access table/database (still from Excel). I want to create a new Access
database everytime I run the code. I am not too familiar with Access objects
in Excel, so any helps will be greatly appreciated. Thanks very much in
advance.

Public Sub updateLoanCharacteristics()
Dim strQuery As String

Set conSQL = New ADODB.Connection
Set rsQuery = New ADODB.Recordset

conSQL.Open "Provider=MSDASQL;DSN=PM_SQL_SERVER_ARCHIVE;"

strQuery="Select * from tblData"

With rsQuery
.ActiveConnection = conSQL
.Open strQuery
ActiveWorkbook.ActiveSheet.Range("AU3").CopyFromRe cordset rsQuery
.Close
End With

conSQL.Close

Set conSQL = Nothing
Set rsQuery = Nothing

End Sub


Regards,
Adrian T