Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Export to MS Access

I am trying to export a few fields from a worksheet to an MS Access
table and I am getting an Automation error when I attempt to run the
following. Any ideas on what I am doing wrong or not doing?

Sub ExcelToAccess()

Dim CN As ADODB.Connection, RS As ADODB.Recordset, r As Long
Set CN = New ADODB.Connection
CN.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=U:\Intranet
\PMdata.mdb;"
Set RS = New ADODB.Recordset
RS.Open "test_dtlChangeOrderdtl", CN, adOpenKeyset, adLockOptimistic
RS.AddNew
RS.Fields("JobNumber") = Range("B2").Value
RS.Update

End If

RS.Close
Set RS = Nothing
CN.Close
Set CN = Nothing

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Export to MS Access

You might try something like this ...

Set connection = CreateObject("ADODB.Connection")

connection.Open "your connection string"
Insert connection
connection.close


Sub Insert(user)

Dim adoCommand

On Error Resume Next

Set adoCommand = New ADODB.Command

With adoCommand
.CommandType = 1
.ActiveConnection = connection
.CommandText = "INSERT INTO MY_SCHEMA.MY_TABLE (MY_COLUMN)
VALUES (?)"
End With


Dim login_VARCHAR
' Go to M$ site and look up the many different versions of
CreateParameter
Set login_VARCHAR = adoCommand.CreateParameter("MY_COLUMN", 200 ,
1, 40)
Call adoCommand.Parameters.Append(issue_app_name_VARCHA R)

login_VARCHAR.Value = Range("B2")

Call adoCommand.Execute
Set adoCommand = Nothing

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Export to MS Access

On Jun 13, 5:34 pm, "
wrote:
You might try something like this ...

Set connection = CreateObject("ADODB.Connection")

connection.Open "your connection string"
Insert connection
connection.close

Sub Insert(user)

Dim adoCommand

On Error Resume Next

Set adoCommand = New ADODB.Command

With adoCommand
.CommandType = 1
.ActiveConnection = connection
.CommandText = "INSERT INTO MY_SCHEMA.MY_TABLE (MY_COLUMN)
VALUES (?)"
End With

Dim login_VARCHAR
' Go to M$ site and look up the many different versions of
CreateParameter
Set login_VARCHAR = adoCommand.CreateParameter("MY_COLUMN", 200 ,
1, 40)
Call adoCommand.Parameters.Append(issue_app_name_VARCHA R)

login_VARCHAR.Value = Range("B2")

Call adoCommand.Execute
Set adoCommand = Nothing

End Sub


But why doesn't what I have work?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Export to MS Access

For starters ... I don't see your SQL statement.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access export [email protected] Excel Discussion (Misc queries) 0 February 9th 09 02:16 PM
Export from Access jhrBanker Excel Discussion (Misc queries) 1 August 7th 07 09:06 PM
Export to Access LJgrnl Excel Programming 0 December 1st 05 05:35 PM
Export from Access tamxwell Excel Discussion (Misc queries) 0 June 28th 05 06:41 PM
export access to excel. change access & update excel at same time fastcar Excel Discussion (Misc queries) 0 June 24th 05 09:27 PM


All times are GMT +1. The time now is 01:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"