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.
'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