Excel to Access - recordset problem

paulpan

New Member
Joined
Sep 24, 2007
Messages
23
I have a problem with the following code. It is not recognising the following variable:

objRecordSet

My knowledge of Access is only in the beginner stage. I have seen plenty of examples of code online that use this but for some reason I canlt get it to work





Sub Populate_Funds()

'On Error Resume Next



Const adOpenStatic = 3
Const adLockOptimistic = 3

Dim objConnection As Object
Dim objRecordSet As ADODB.Recordset


Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")



'Set objRecordSet = New ADODB.Recordset

objConnection.Open _
"Provider = Microsoft.Jet.OLEDB.4.0; " & _
"Data Source = C:\Documents and Settings\ppanebianco\Desktop\Funds Table.mdb"

objRecordSet.Open "SELECT * FROM GeneralProperties", _
objConnection, adOpenStatic, adLockOptimistic

objRecordSet.AddNew
objRecordSet("Fund") = "atl-ws-99"
objRecordSet("Department") = "Human Resources"
objRecordSet("OperatingSystem") = "Microsoft Windows XP Professional"
objRecordSet.Update

objRecordSet.Close
objConnection.Close




End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Change

Code:
Dim objRecordSet As ADODB.Recordset

to


Code:
Dim objRecordSet As Object
 
Upvote 0

Forum statistics

Threads
1,215,461
Messages
6,124,955
Members
449,199
Latest member
Riley Johnson

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