VBA & Acc2007 attachments: an adventure

geoB

Registered User.
Local time
Yesterday, 19:44
Joined
Oct 10, 2008
Messages
68
I've made myself a small database to catalog my photos. There were about 300 photos in a number of subdirectories to ..\MyPictures. The file names, complete with explicit path, were in a field in tblPhotos, loaded by a small routine.

I then started flopping around with code to update the FileData spec of the child recordset for an Attachment type field. Don't know about you, by my code is rarely right the first time. Found that after fixing one bug the code started hanging up when I tried to update the child field. I was told I was creating a duplicate value. Curious. As far as the table was concerned, the attachment field had no values. After a couple of iterations I decided to compact the database and got a message to the effect that another user had the database open. Double curious - this was totally impossible.

What resolved the situation was shutting down Access, reopening the database then compacting it. I was then able to run my code to update the attachment field with the file name.

So here's a solution in case anyone else runs into a similar situation.

g
 

Users who are viewing this thread

Back
Top Bottom