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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
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,223,268
Messages
6,171,100
Members
452,379
Latest member
IainTru

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