Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Exporting contents of range to Access...HELP!
I've got the following code. What I'm trying to is export the contents
of a range into an Access table called Scorers. The range C22:E22 contains 'fred','2','2' which correspond to the fields name/age/score. An error occurs when creating the SQL string. Do I need to use a loop and individually move each bit of data? Any help greatly appreciated Jason Sub AddToAccess() Dim cnAccess As ADODB.Connection Dim sConnect As String Dim sSQL As String 'create connection string sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & ThisWorkbook.Path & "\Access Experiment.mdb" 'create SQL string sSQL = "INSERT INTO Scorers (name,age,score) VALUES (" & Application.Transpose(Range("C22:E22")) & ";" 'Range("C22:E22") & ";" '('skelly','2','2');" 'make connection and get get the SQL query recordset Set cnAccess = New ADODB.Connection cnAccess.ConnectionString = sConnect cnAccess.Open cnAccess.Execute sSQL, , adCmdText + adExecuteNoRecords 'close the connection cnAccess.Close Set cnAccess = Nothing End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Exporting data range from Excel to Access | Excel Programming | |||
Exporting datagrid contents to Excel using ASP.NET | Excel Programming | |||
Exporting excel cell contents to word document | Excel Programming | |||
Exporting multiple cell contents into word document | Excel Worksheet Functions | |||
Exporting from Access | Excel Worksheet Functions |