"Record is deleted." Cannot delete attachment file when there's a field of FileName... (1 Viewer)

longlive520

New member
Local time
Today, 09:16
Joined
Apr 2, 2021
Messages
3
I have a table, and there's two field, one is MyDate(which is used to record the date information, the data structure is Date), another is MyFile(which is used to record the file, the data structure is Attachment).

And now, i creat a Form which contains three column, MyDate, MyFile, and MyFile's Filename.

Now, in the Form, MyFile's Filename will show the name of MyFile.

But when i delete MyFile's Attachment, there will be wrong, the attachment file cannot be deleted.

what should i do?
 

Attachments

  • Test.accdb
    3.5 MB · Views: 123

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:16
Joined
Oct 29, 2018
Messages
16,194
Hi. Welcome to AWF!

Not sure what your ultimate goal is, but Attachment fields can contain more than one file in it, so showing a filename on your form could also potentially be misleading as well.

Regarding your current problem, I guess what you could try to do is remove the filename from your record source and simply look it up on the form (untested, but I think it's worth a try).

Good luck!
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:16
Joined
Oct 29, 2018
Messages
16,194
Hi. Welcome to AWF!

Not sure what your ultimate goal is, but Attachment fields can contain more than one file in it, so showing a filename on your form could also potentially be misleading as well.

Regarding your current problem, I guess what you could try to do is remove the filename from your record source and simply look it up on the form (untested, but I think it's worth a try).

Good luck!
I did a quick test... This worked for me as the Control Source for the FileName Textbox (after removing it from the Record Source, of course)...

Code:
=DLookUp("MyFile.Filename","tbl1","ID=" & Nz([ID],0))
 

Isaac

Lifelong Learner
Local time
Yesterday, 18:16
Joined
Mar 14, 2017
Messages
5,553
You could write code to show the filenames of all attachments to a given record, then write code that allows someone to select a given file and delete it. I know that would work, because I do it on Sharepoint attachment columns.

I am not sure why the built-in Access Attachments/Remove/Save interface is not working in this case - but I never allow users to use this anyway, as it is harder to trap events and control the situation anyway
 

isladogs

CID VIP
Local time
Today, 02:16
Joined
Jan 14, 2017
Messages
15,281
First of all, using attachment fields is not recommended by most experienced developers.
Attachments are a type of multivalued field which depends on a hidden system table and using these will result in your database becoming very large and performance will suffer.
Instead store the path to the external files in your database. You will still be able to view these from Access

Secondly if you MUST use an attachment field, have you tried just delating/adding items from the table itself...or from a datasheet form?
 

longlive520

New member
Local time
Today, 09:16
Joined
Apr 2, 2021
Messages
3
Hi. Welcome to AWF!

Not sure what your ultimate goal is, but Attachment fields can contain more than one file in it, so showing a filename on your form could also potentially be misleading as well.

Regarding your current problem, I guess what you could try to do is remove the filename from your record source and simply look it up on the form (untested, but I think it's worth a try).

Good luck!
If i don't use the FileName, i must double click the Attachment to know the attach file. Through adding a field in the Form, i can see the attach file's name in the Form directly.
Through looking it up on the form and it works!!!
Thank you very much!
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:16
Joined
Oct 29, 2018
Messages
16,194
If i don't use the FileName, i must double click the Attachment to know the attach file. Through adding a field in the Form, i can see the attach file's name in the Form directly.
Thank you very much!
Hi. Did you see my post where I showed you how to display the name of the Attachment? Also, what do you think about what I said of how would you display the correct filename if you had more than one attached file?
 

longlive520

New member
Local time
Today, 09:16
Joined
Apr 2, 2021
Messages
3
Hi. Did you see my post where I showed you how to display the name of the Attachment? Also, what do you think about what I said of how would you display the correct filename if you had more than one attached file?
I have solved this problem accroding your answer, thanks a lot!!!
 

Users who are viewing this thread

Top Bottom