Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to run the following but I am getting the following error
"object variable or With Block Variable not set", any ideas why?? Sub Insert() Dim objCommand As ADODB.Command Dim rsData As ADODB.Recordset Dim lRecordsAffected As Long Dim lKey As Long Dim sConnect As String ' On Error GoTo ErrorHandler 'connection string sConnect = "Provide=Microsoft.ACE.OLEDB.12.0; Data Source=U: \intranet\pmdata.mdb; Mode=Share Exclusive" 'command object for statements Set ojbCommand = New ADODB.Command objCommand.ActiveConnection = sConnect 'insert statement objCommand.CommandText = "INSERT INTO table1(Test1, Test2) VALUES('test456', 'test4567');" 'execute statement objCommand.Execute 'RecordsAffected:=lRecordsAffected, Options:=adCmdTxt Or adExecuteNoRecords If lRecordsAffected < 1 Then Err.Raise Number:=vbObjectError + 1024, Description:="Error executing Insert Statement." ErrorExit: 'Destroy ADO objects Set objCommand = Nothing Set rsData = Nothing Exit Sub ErrorHandler: MsgBox Err.Description, vbCritical Resume ErrorExit End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Write data to Access table with INSERT when table has auto number | Excel Programming | |||
Importing data from Access to Excel, but I need to vary the table from Access | Excel Programming | |||
Insert Literal in Access Table using JETSQL | Excel Programming | |||
Is it possible to insert an Access Table object into Excel? | Excel Programming | |||
Is it possible to insert an Access Table object into Excel? | Excel Programming |