Topics Search

How do I save "Attachment" objects automatically?

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

Similar posts...

 

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

How do you file save an 'Attachment' content through code? Icon
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

Remove specific type of attachment from all records in table Icon
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,
 

Color in VBA

Color in VBA Icon
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
 

Add a new record with attachment using VBA

Add a new record with attachment using VBA Icon
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

Saving an image on the clipboard to the attachment type in Access 2010 Icon
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?
 

Add an attachment to form

Add an attachment to form Icon
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
 

SendObject with dynamic attachment name

SendObject with dynamic attachment name Icon
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, "[email protected]", , , 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, "[email protected]", , , Subject, Body, Yes
 

Dlookup image for attachment with criteria

Dlookup image for attachment with criteria Icon
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
 

Hidden Objects in Navigation window

Hidden Objects in Navigation window Icon
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
 

IIF statement for attachments

IIF statement for attachments Icon
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