This is an Access question, but it may spill over into requiring non-Access solutions. Please let me know if I should look for this answer elsewhere (and if you have suggestions on where to find it).
My Orders Database creates a folder on our server for each new order we receive (i.e. each new record entered).
It does this as a part of an OnClick Event from a command button.
This folder structure on the server is very important. Each folder contains all of the files used for that particular survey order. It contains autocad drawings, pdf copies of invoices, photos, etc.
There are several people who access these folders. For example, The field crew will save their field data and pictures into the folder. The draftsman will work with autocad files in that folder. Etc, etc etc.
The problem we run into sometimes is that a folder will accidentally get deleted, renamed, or moved into a neighboring folder, due to carelessness with the mouse or a keyboard stroke. This is a bad bad thing to have happen.
I am not very familiar with what kind of options I have as far as protecting a folder from deletion, renaming, or being moved, while still allowing unfettered access to create, delete, and modify the files inside that folder.
Here's the part relevant to Access: if Windows even has the capability of the type of protections for folders that I need... is there a way through VBA to assign those protections to a folder that is created with the VBA code?
Here is how the relevant portion of the OnClick event looks:
Expand|Select|Wrap|Line Numbers
- ' Create Folder on O: drive
- yr = Left([FILE_NO], 4)
- stOrdnum = Right([FILE_NO], 4)
- stFileNumber = [FILE_NO]
- stPathName = "O:\Orders_" & yr & "\" & [FILE_NO]
- stFileName = [FILE_NO] & ".rtf"
- stPFName = stPathName & "\" & stFileName
- If stOrdnum = "0001" Then
- MkDir ("O:\Orders_" & yr)
- End If
- If Dir$(stPathName, vbDirectory) <> "" Then ' Does Path Already Exist?
- ' Yes No Box
- Msg = "The directory " & stPathName & " Already exits! Do you want to continue?" ' Define message.
- Style = vbYesNo ' Define buttons.
- Title = "Directory Already Exists" ' Define title.
- Response = MsgBox(Msg, Style, Title)
- If Response = vbNo Then ' User chose No
- GoTo Exit_Create_Order_File_Structure_Click
- End If
- Else
- MkDir Path:=(stPathName) ' Create Directory Structure
- End If