Topics Search

How do I save "Attachment" objects automatically?

How do I save "Attachment" objects automatically?
Views: 125
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:

More topics

 

How do you file save an 'Attachment' content through code?

Preview
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

Preview
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,
 

IsNull not catching all nulls

Preview
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

Preview
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
 

Save Report in Attachment

Preview
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?
 

SendObject with dynamic attachment name

Preview
- 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:
 

Add a new record with attachment using VBA

Preview
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".
 

Saving an image on the clipboard to the attachment type in Access 2010

Preview
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?
 

Dlookup image for attachment with criteria

Preview
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

Preview
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