View/Load Access attachment from excel userform

AceandVecky

New Member
Joined
Jun 7, 2019
Messages
7
Good Day.
Please Help me or advise suggestion or Tips on how to load, View or Download an attachment from a selected record in an MS Access table using excel macro.

I can however modify/Add/Delete data in access using an ADODB Connection but i dont have experience in working with attachment. Thanks in advance.
 

Some videos you may like

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

ranman256

Well-known Member
Joined
Jun 17, 2014
Messages
1,900
Normally you just dbl-click the attachment,then click SAVE.
 

AceandVecky

New Member
Joined
Jun 7, 2019
Messages
7
@ranman256
yeah thats correct. but what Im trying to achieve is do that using a macro code from Excel. I have an excel userform as a frontend and an access database as the backend.

Thanks
 

ranman256

Well-known Member
Joined
Jun 17, 2014
Messages
1,900
something like :

Code:
Dim rst As ADODB.Recordset
Dim conn As New ADODB.Connection

vTarg = "c:\temp\myFile.jpg"

If Not FileExists(vTarg) Then
'extract photo attachement
sConnStr = "your connection string"
conn.ConnectionString = sConnStr
conn.Open

    '1st rst is the table
sSql = "select * from tInstallDb"
Set rst = conn.Execute(sSql)
'2nd rst is the attachment (rst in a rst)
Set rstChild = rst.Fields(0).Value
rstChild.Fields("FileData").SaveToFile vTarg
End If
Code:
Public Function FileExists(ByVal pvFile) As Boolean
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
FileExists = fso.FileExists(pvFile)
Set fso = Nothing
End Function
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,263
Messages
5,510,179
Members
408,779
Latest member
Lermiapolar

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top