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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Pedie

I tried the code with only minor changes, eg table/database name, and it worked.
 
Upvote 0
Hi Norie...
'm running this code from excel. Try to send attachment to access db table.
Running this access works perfectly.
 
Upvote 0
Pedie

It wasn't clear the code is in Excel.

LoadFromFile is not in the DAO library in Excel even if you search in the ObjectBrowser.

That explains the problem, I'm afraid I can't find a solution.

Why not just store the file name in text field instead of using an attachment field?
 
Upvote 0
yes, excel does not support this method LoadfromFile...:)
yes Norie, maybe that is one option, storing file as file fullname only in text...

Thanks again...
 
Upvote 0
You need the Microsoft Office 14.0 Access database engine Object Library



then you need to set the field to a DAO.Field2 object

Dim fld As DAO.Field2
Set rst = dbs.OpenRecordset("Sometablesomewhere")
Set fld = rst("FileData")
fld.LoadFromFile "c:\yourfile"
 
Upvote 0
Are you referring to Miscrosoft Acesss 12.0 Object Library?
it is already referenced...still same issue.
 
Last edited:
Upvote 0
Try to reference the Microsoft DAO 3.6 Object Library

No:

It has to be the MS Office xx Access database engine object lib
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,684
Members
449,116
Latest member
HypnoFant

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