How do I save "Attachment" objects automatically?

I have a need to output a list of about 22000 entries, each one with a JPG attachment, into a directory (i.e. save every attachment of every entry back into a file)

However, there doesn't seem to be any immediate ways to do this other than clicking on each entry, then clicking on its attachment, and then clicking "save as".

It would seem sensible that there must be an code specific way to do it, seeing as that functionality is already coded in the attachment "Save As" button. Is there anyway to invoke that function automatically

Sponsored Links:

Related Topics

How do you file save an 'Attachment' content through code?
I have a need to output a list of about 22000 entries, each one with a JPG attachment, into a directory (i.e. save every attachment of every entry back into a file)

However, there doesn't seem to be any immediate ways to do this other than clicking on each entry, then clicking on its attachment, and then clicking "save as".

It would seem sensible that there must be an code specific way to do it, seeing as that functionality is already coded in the attachment "Save As" button. Is there anyway to invoke that function automatically


Remove specific type of attachment from all records in table
I have table call "empTable" and it has an Attachment field called "Attachment". Some of the records has empty Attachment field and some record has one attachment and some has two and the attachment types are jpeg and pdf.

I want to remove all the pdf from all the records in this table automatically with VBA or something,


Save Report in Attachment
I have a Exam DB where we genreate the Question papers as rtf ( M S WORD File). We have to attach the above file manually to our attachment field
Table:Exam_Papers
Attachment Field:Privious_Papers
Can this be done through code automatically?


IsNull not catching all nulls
I have a field in Event table called EventAttachment. EventAttachment is an Attachment datatype. I want the code to see if it is null and if so put No Attachment in the caption. Sometimes it works and sometimes it doesnt. For instance, Record 455 has no attachments but it displaying Attachment.

Below is the code:


If IsNull(DLookup("EventAttachment", "Event", "CompanyID = " & Me!txtCompanyID)) Then
Me!cmdAttachments.Caption = "No Attachment"
Me!cmdAttachments.ForeColor = vbRed
Else
Me!cmdAttachments.Caption = "Attachment"
Me!cmdAttachments.ForeColor = -2147483615
End If

Does anyone see anything wrong with the


Color in VBA
I have a button called cmdImage. Caption = "Attachment" and ForeColor = TextDark.

I want it to display "No Attachment" in red when empty, and "Attachment" in TextDark when it's not. That way, I will not have to click on the button to see if there are any attachments.

I created the following code:

If IsNull(DLookup("EventAttachment", "Event", "CompanyID = " & Me.txtCompanyID)) Then
Me.cmdImage.Caption = "No Attachment"
Me.cmdImage.ForeColor = vbRed
Else
Me.cmdImage.Caption = "Attachment"
Me.cmdImage.ForeColor = vbBlue
End If

The problem is: vbBlue is not the TextDark blue I was using.

How do I get it to leave the default values or to put the correct color blue back?

Or, should the above code be written differently


SendObject with dynamic attachment name
- I am attempting to send a PDF of a report via email and the SendObject function but I don't know how to create the attachment with a dynamic name. What happens is the name of thereport gets passed to the name of the attachment.

DoCmd.SendObject acSendReport, "rpt_Certificate", acFormatPDF, "replace.me@domain.com", , , Subject, Body, Yes, ""

Something similar to this:


Saving an image on the clipboard to the attachment type in Access 2010
Two weeks ago I started to use Access for the first time and yesterday looked at VB. Mind you, I have extensive experience in Pascal, assembler, some C and QBasic/GWBasic in the DOS days.

I'm using Access 2010 and the attachment type in a table. I can generate a form and load an image from a file into this table.
What I would like to do is save the image captured onto the clipboard into the attachment field of the table.
Ie ALT+Printscreen then press a button on the Access form that puts this into the attachment field. Pressing Cntl+V on the attachment doesn't work

I imagine the VB code for the button press would probably be a two part process -
1. Get the image from the clipboard and save as a file ie JPG.
2. Load the JPG file into the attachment field.

I have the below code but it references a excel variable "xlBitmap" and won't compile in Access VB?


Hidden Objects in Navigation window
One day, out of the blue, this started happening: I create new queries & reports but they do not show up in the Navigation Pane. Instead, they automatically become "hidden objects" there. I do not choose to have the "show hidden objects" option checked in the Navigation Options b/c I have so many of them. To make it even more of a nuisance, if I do go ahead and not have the "show hidden objects" option checked, then create a query or report, and then go to the Navigation Options and check that option to now show the hidden objects, the new ones I just created won't show up! I have to get out of Access completely and then go back in


Add a new record with attachment using VBA
At the submit button, I need the values to be updated to the table.

Here is the code for the "add record" that I created. I added this line MySet!trAttach = Attachment
in the code for Attachment and get an error "type mismatch".


Add an attachment to form
I am trying to add an attachment to a subform. I update the control source to say "Attachment" in the properties section which matches the name of the field in the table where it's pulling from.

When I open in form view and right-click on the text box (for attachment) the manage attachments selection is greyed out. If I go to the table I can open the attachment.

Any idea why this isnt working in the form


Add multiple records with one field
Please find attached my form, the "Slide" field is of type attachment. This field usually has min 5 attachments, is there a way that a record can be made for each attachment added, the Start and End Date will be the same for every attachment.

Can someone please help, it takes a long time to add each attachment seperately.


Dlookup image for attachment with criteria
learner who has learned DAO (somewhat), but not used control source (I was told not to), but in this instance, I'm simply looking up an image to display. This is my expression:

DLookUp("[People]![Picture]","People","[People]![PeopleID]=txtIDMother")

I'm wanting to retrive into my form the attachment "Picture" (automatically named by Access for my attachment table field) from the "People" table for the field where the "txtIDMother" txt box (already retrived by DAO on form_load procedure) equals the "PeopleID" primary key in the "People" table.

The control source accepts the code, but it doesn't load onto the form - only flashes briefly.

Edit: Incidently, I just discovered that I can actually put an SQL statement in the control source. I tried, but the results are exactly the same as above, only faster. Here is my SQL:

="SELECT People.PeopleID,People.Picture.FileData,People.Pic ture.FileName, People.Picture.FileType
FROM People
WHERE (People.PeopleID)=" & [txtIDMother


SendObject with dynamic attachment name
I am attempting to send a PDF of a report via email and the SendObject function but I don't know how to create the attachment with a dynamic name. What happens is the name of the report gets passed to the name of the attachment.

DoCmd.SendObject acSendReport, "rpt_Certificate", acFormatPDF, "replace.me@domain.com", , , Subject, Body, Yes, ""

What I would like to do is name the attachment from a field.

Something similar to this:

DoCmd.SendObject acSendReport, "rpt_Certificate" [TaskSR] & ".PDF", acFormatPDF, "replace.me@domain.com", , , Subject, Body, Yes


Can't save database objects when changes made
This has happened to me several times in the past. I make minor changes to a report and when I go to save it or close it out, it asks, "Do you want to save changes?" Of course I say yes and it just sits there, not closing out the report tab. The only way around it that I have found is to re-write the report, from scratch. Much time wasted. Anyone ever see this before?


Cannot Convert from 2000 to 2010
I have a 2000 database that just will not convert over.

Nothing is open. No one is in it besides me. No linked tables or anything fancy.

I'm doing:

Save and Publish
Save Database As
Access Database (*.accdb)

I then hit Save As and it asks me if I would like to close all objects. I say yes, specify the save location and name and then it tell me "Could not use "file location and name is here"; file already in use.

Anyone have any tips?

Microsofts site was no


IIF statement for attachments
I am having problem setting up a querry with IIF statement.

I have made a querry which shows if there are attachments in table.
if there is an attachment it shows (something like) @(1) and if there is no attachment it shows @(0) in querry filed.

what I am trying to do is, if there is an attachment it should say "YES" and If there is no attachment it should say "NO"

for which I have tried the following formulas in querry but its none are working.

TEST: IIf([purattach] Is Null,"YES","NO")
TEST: IIf([purattach.FileData] Is Null,"YES","NO")
TEST: IIf([purattach.FileName] Is Null,"YES","NO")
TEST: IIf([purattach.FileType] Is Null,"YES","NO


Setting an alert that a payment is overdue
I have a reservation database that holds data for all guests with bookings; in it, I have the folllowing fields:

One for their outstanding balance "Balance 5" (circled red in the attachment)
One that holds the due date for the balance of their holiday "Due Date 2" (circled blue in the attachment)
One for an alert message "Payment" (circled green in the attachment)

I'm trying to create something (possibly an iif argument ?) which will show a message of OVERDUE in the "Payment" field if both of the following are true:

"Balance 5" is greater than 0.00 and "Due Date 2" is less than today's date.

You can see from the attachment that I've had a go but it isn't working, it keeps bringing up the Name error message - can anyone help please ?


how to use select * from where tblFileImport.bulletin_imp.FileData Like
I don't know how to do this search. I have bellow this query based on 2 tables where the second table has an attachment field. The searching should be based on the content of the attachment,for ex: if the files(that are stored in the attachment field) contain a word like "tracking" then I want to pull the attachments and their data.


Dirty Save Issue
I have the below code execute in a check box's "Click" event. Every time blnUserActive = True I receive the message pictured in attachment. How do I avoid this? I have tried putting the dirty check before and after the save record command.


Setting an alert that a payment is overdue
I have a reservation database that holds data for all guests with bookings; in it, I have the folowing fields:

One for their outstanding balance "Balance 5" (circled red in the attachment) One that holds the due date for the balance of their holiday "Due Date 2" (circled blue in the attachment). One for an alert message "Payment" (circled green in the attachment)

I'm trying to create something (possibly an iif argument ?) which will show a message of OVERDUE in the "Payment" field if both of the following are true:

"Balance 5" is greater than £0.00 and "Due Date 2" is less than today's date.