VBA Query fails if Attachment field is present

pbassett

Active Member
Joined
May 5, 2004
Messages
358
My query fails with "Invalid Operation run-time error -2147467259 (80004005)". It only fails when an Attachment field is in the table.
The query runs correctly when I remove the Attachment field so I'm sure its mere presence is the cause.
Is anyone aware of this? My first though is to create a separate Attachments table, but now I can't figure out how to add the Attachment as a subform. The Attachment wizard doesn't display the Attachment field as an available field. I'm sure I can display the attachments so any help is appreciated.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Perhaps you have uncovered another reason to not use attachment fields in an Access table, but it does sound bizarre if you're saying the mere presence of the field in the table causes this. As I read your post, the field is not part of the query at all. Yet I can't imagine why you'd want the attachment to appear in a subform. AFAIK, it can't anyway (unless these are images, and you're not saying), and the fact you're asking makes me think that maybe you do have it in your query. Why else would you want the attachment to "appear" on a form if it wasn't?

Many experienced developers won't/don't use attachment fields. Instead, a field for file paths is used, and if the attachment is an image, an image control handles the display, getting the image according to the image file path for each record. Attachment fields cause rapid db bloat and can quickly lead to reaching the maximum GB size for a table.
 
Upvote 0
So you're creating sql in code. Your thread title and post made no mention of that; just that it was a query. ADO appears to be possible for this but can be more difficult. ADO didn't turn out to be the greatest thing since sliced bread. M$soft doesn't advocate for it so much any more.
 
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,150
Members
448,552
Latest member
WORKINGWITHNOLEADER

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top