Compile Error: Method or Data Member not found. Data Append MVF to Access From Excel.

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi Guys!:)
'm try to upload file as attachement to Access from Excel.
This perfectly works in Access to Access even Accross databases but from Excel to Access this Problem is happening...
it errors in Underlined Code line below
Please advice.

Code:
[/FONT]
[FONT=Courier New]Dim db As DAO.Database
Dim ws As DAO.Workspace
Dim rst As DAO.Recordset
Dim MVFrst As Recordset[/FONT]
[FONT=Courier New]Dim rs As DAO.Recordset[/FONT]
[FONT=Courier New]
Set ws = DBEngine.Workspaces(0)
Set db = ws.OpenDatabase("C:\Budget_Expense.accdb", False, False, "MS Access;PWD=")
Set rst = db.OpenRecordset("Select * FROM MyTb;", dbOpenDynaset)[/FONT]
[FONT=Courier New]rst.AddNew
rst!Expense_Detail = "Test Title"
Set MVFrst = rst.Fields("MyAttachment").Value
MVFrst.AddNew
[U]MVFrst.Fields("FileData").LoadFromFile "C:\Book1.xls"
[/U]MVFrst.Update
rst.Update[/FONT]
[FONT=Courier New]If Not rst Is Nothing Then
rst.Close
Set rst = Nothing
End If
If Not db Is Nothing Then
db.Close
Set db = Nothing
End If
If Not ws Is Nothing Then
Set ws = Nothing
End If
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
The right reference is the one Charles suggested earlier which is in Excel and you don't need to change any of the code.

PS If you get a name conflict whem you add that reference then uncheck the DAO reference.
 
Upvote 0
Pedie

Which reference did you eventually use?
 
Upvote 0

Forum statistics

Threads
1,215,220
Messages
6,123,695
Members
449,117
Latest member
Aaagu

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