Object does not support... when INSERTing into Access DB

pitaszek

Board Regular
Joined
Jul 20, 2012
Messages
85
Hi Guys,

I can't figure out what's wrong.

I want to insert only one value into one field but the number of fields is bigger (if it matters).

I reworked it from early binding to late binding.. maybe I am missing something or my query is super bad but it should not as similar one works on different db.

Generally it takes CleintFundName from the outside but I changed it to fixed value 'abcd'.

Code:
Private Const AccessConStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\networkdrive\myaccessdb.accdb;Persist Security Info=False; Jet OLEDB:Database Password=xxx;"
Sub ConnectToDB(ByVal ClientFundName, ByVal SQLStr)
   
    Dim Date1 As Date
    'MsgBox ClientFundName
    
    Dim TESTDB As Object
    Dim TESTDBCmd As Object
    
    Set TESTDB = CreateObject("ADODB.Connection")
    Set TESTDBCmd = CreateObject("ADODB.Recordset")
    
    TESTDB.ConnectionString = AccessConStr
    
    TESTDB.Open
    
    TESTDBCmd.ActiveConnection = TESTDB
    'GetInsertTexto ClientFundName, SQLStr
    'MsgBox SQLStr
    TESTDBCmd.CommandText = "INSERT INTO Tracker (Client_Fund_Name) VALUES ('abcd')"
    
    TESTDBCmd.Execute
    
    TESTDB.Close
    
    Set TESTDB = Nothing
    
End Sub
Sub GetInsertTexto(ByVal ClientFundName, ByRef SQLStr)
'MsgBox (Name1 & " " & Last_Name)
SQLStr = "INSERT INTO Tracker (Client_Fund_Name)" _
& "VALUES (" & "'" & ClientFundName & "'" & ")"
    
End Sub

Regards,
Witek
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I don't think you can set CommandText on a Recordset. Don't you want:

Code:
Set TESTDBCmd = CreateObject("ADODB.Command")

?

WBD
 
Upvote 0
A Recordset doesn't have a CommandText property or an .Execute method. I think you meant:

Rich (BB code):
Set TESTDBCmd = CreateObject("ADODB.Command")
 
Upvote 0

Forum statistics

Threads
1,215,427
Messages
6,124,831
Members
449,190
Latest member
rscraig11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top