Solved

Retrieve the file

Posted on 2013-12-03
5
314 Views
Last Modified: 2013-12-18
Hi,
I have the relevant picture file stored in the Access 2013 table. what is the way/query to retrieve the picture file inside that?
0
Comment
Question by:HuaMinChen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 40

Expert Comment

by:als315
ID: 39694556
If you have path to image in table, you can use method from my article:
Images on continuous forms
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 39694561
Sorry, there are already images stored in the table but I want to retrieve the file from the table.
0
 
LVL 21

Accepted Solution

by:
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 135 total points
ID: 39694726
If you have images store in the new attachment data type this here is an example:

Saving an Internal Attachment Back to a File
On Error GoTo Err_SaveImage

Dim db As DAO.Database
Dim rsParent As DAO.Recordset2
Dim rsChild As DAO.Recordset2

Set db = CurrentDb
Set rsParent = Me.Recordset

rsParent.OpenRecordset

Set rsChild = rsParent.Fields("AttachmentTest").Value

rsChild.OpenRecordset
rsChild.Fields("FileData").SaveToFile ("c:\")

Exit_SaveImage:

Set rsChild = Nothing
Set rsParent = Nothing
Exit Sub

Err_SaveImage:

If Err = 3839 Then
MsgBox ("File Already Exists in the Directory!")
Resume Next

Else
MsgBox "Some Other Error occured!", Err.Number, Err.Description
Resume Exit_SaveImage

End If

Open in new window

0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 39694735
Sorry, how to point to the relevant table within Access DB, in the above codes?
0
 
LVL 21

Assisted Solution

by:Boyd (HiTechCoach) Trimmell, Microsoft Access MVP
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 135 total points
ID: 39696282
The code I posted is for the click event of a command button. Havinfg the code behind the form makes it easier.

With the code behind the form you will need to change is the following line:

' open a recordset on the Attachment field
Set rsChild = rsParent.Fields("AttachmentTest").Value

Open in new window

You will need to change the AttachmentTest to be your field name


If you use a code Module:

You first open a recordset for the table with the attachment data type field

' use the form's record source
Set rsParent = Me.Recordset

Open in new window


Change the above line to open the desired recordset

Also in:
' open a recordset on the Attachment field
Set rsChild = rsParent.Fields("AttachmentTest").Value

Open in new window

You will need to change the AttachmentTest to be your field name

Either way be sure to set he output path:

rsChild.Fields("FileData").SaveToFile ("c:\")

Open in new window


Change c:\ to be the desired output folder

FWIW:
As you can see, dealing with the Attachment data type is not easy. It requires VBA coding and DAO knowledge.  I avoid them.

Boyd Trimmell, Microsoft Access MVP
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question