Solved

Prevent certain data types from Attachment field

Posted on 2011-09-25
5
251 Views
Last Modified: 2012-05-12
Hello experts ,
is there any way to prevent user from uploading certain data types to the attachment field? i want to insert only picture files and reject all other file types supported by the attachment field by showing a warning message.
How can this be achieved?
0
Comment
Question by:stathisx
  • 4
5 Comments
 
LVL 10

Expert Comment

by:Tony Barkdull
ID: 36596039
In you file upload, use this to specify type and size. This is from my asp page

'The the properties of the upload
File.ValidFileTypes = "jpg,gif,png"
File.MaxSize = 1024*1024
File.Overwrite = false 'Do not overwrite, create unique filename
0
 
LVL 1

Assisted Solution

by:stathisx
stathisx earned 0 total points
ID: 36596065
there is no such property in the attachment field !
0
 
LVL 1

Assisted Solution

by:stathisx
stathisx earned 0 total points
ID: 36596079
there is .filetype that may be used in vba to control which data types should be allowed ( just a thought)
0
 
LVL 1

Accepted Solution

by:
stathisx earned 0 total points
ID: 36596164
i found the solution :

Private Sub uploadpath_BeforeUpdate(Cancel As Integer)
If Me.uploadpath.FileType <> ".jpg" Or Me.uploadpath.FileType <> ".png" Or Me.uploadpath.FileType <> ".jpeg" Then
MsgBox "denied attachment"
Cancel = True
End If
End Sub

it does the job :)
0
 
LVL 1

Author Closing Comment

by:stathisx
ID: 36890339
i found that the filedata property for the attachment field does what i really wanted. so in before update event of the attachment field a used this code to validate the attachment uploaded and if does not meet my criteria to reject it.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now