Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing default file location when adding attachments

Status
Not open for further replies.

Aspen77

Technical User
Sep 20, 2012
41
US
I created a form that allows a user to add an attachment. This is working fine however, the user is having to browse through many folders to get to a location where all the files are stored. Where can I change the default file location when adding an attachment?
 
You don't give any indication of how you are doing this so have assumed you are using filedialog

so try this...

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
I assume the opposite and you are using an attachment control
AFAIK the answer is no. You could roll your own attachment control through code.

Use a file browser to get the path of the file to add. Then pass that to this code
Code:
Public Sub loadAttachFromFile(strPath As String, rsAll As DAO.Recordset, attachmentFieldName As String)
  'An attachment field has a recordset of attachments stored behind the scenes
  Dim rsAtt As DAO.Recordset
  'Add a new record to the tables recordset
  Set rsAtt = rsAll.Fields(attachmentFieldName).Value
  rsAll.Edit
    rsAtt.AddNew
     'This is the confusing part.  The value property of an attachment field returns a recordset of attachments
     'All recordset of attachments has a field named filedata which holds the data.
     'The loadfromfile data loads an attachment from a path
     rsAtt.Fields("FileData").LoadFromFile (strPath)
    rsAtt.Update
  rsAll.Update
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top