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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Change

Code:
Dim objRecordSet As ADODB.Recordset

to


Code:
Dim objRecordSet As Object
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,588
Members
449,089
Latest member
Motoracer88

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