Results 1 to 8 of 8
  1. #1
    Esmatullaharifi is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    40

    Question Attachment storing in file server

    Hello Dears!
    I have a form that connected to SQL server 2014 table, SQL server does not support attachment data type I want to store related form attachment in the server where SQL server is located. I need a code that can select the attachment (photo,doc) from PC and can upload it to the specific folder shared on Server computer, And vice versa (can access the specific file using its name from specific server location).


    Or any other better way you can suggest me.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Detach the docs and store them in a OBJ field , or BLOG. Some binary storage in a child table.

    if you can't do that, store the actual files in a server folder, then store the path in the db.

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    what do you mean by 'upload'

    If you are just copying a file with a known name/path to another known folder you can use filesystemobject commands to manipulate files. Look at the methods:

    https://msdn.microsoft.com/en-us/lib...=vs.84%29.aspx

  4. #4
    Esmatullaharifi is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    40
    I tried but i can't use filesystemobject commands because i can't find that.

  5. #5
    Esmatullaharifi is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    40
    I used this code that worked very well but i want the file name must be a variable that i can change it using combo box located in my form. I mean the name of the file with its extension must a variable. (database.txt as a variable)
    Code:
    Function GetFSO() As Object ' Scripting.FileSystemObject
      On Error Resume Next
      Set GetFSO = CreateObject("Scripting.FileSystemObject")
    End Function
    
    Sub FSOCopyFile(fso As Object, sourceFolder As String, _
      destinationFolder As String, Optional overwrite As Boolean = True)
      fso.CopyFile sourceFolder, destinationFolder, overwrite
    End Sub
    
    Private Sub Command2_Click()  
    Dim fso As Object ' Scripting.FileSystemObject
    Set fso = GetFSO
    If fso Is Nothing Then
      Exit Sub
    End If
    ' copyfile example
    FSOCopyFile fso, "D:\database.txt", "D:\lictures\"
    End Sub

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    can't find what? you'll have to be more specific.

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    Assume your form has three fields
    fldSourceFile contains the name of the file
    fldSourceDir contains the name of the directory the file currently resides
    fldTargetDir contains the name of the directory you are copying the file to

    assuming it is impossible to choose a directory or file that does not exist

    Code:
    Private Sub Command2_Click()  
    Dim fso As Object ' Scripting.FileSystemObject
    dim sSourceFile as string
    dim sSourceDir as string
    dim sTargetDir as string
    
    Set fso = GetFSO
    If fso Is Nothing Then
      Exit Sub
    End If
    ' copyfile example
    sSourceFile = fldSourceFile 
    sSourceDir = fldSourceDir 'assumes the last character has is a \ otherwise you have to insert one using & "\" & between sourcedir and sourcefile instead of just &
    sTargetDir = fldTargetDir
    
    FSOCopyFile fso, ssourcedir & ssourcefile , stargetdir
    End Sub

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by rpeare View Post
    can't find what? you'll have to be more specific.
    Maybe a reference issue ?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. attachment data type in SQL Server
    By Esmatullaharifi in forum SQL Server
    Replies: 3
    Last Post: 05-15-2015, 12:07 AM
  2. File Attachment Field
    By davek81 in forum Forms
    Replies: 2
    Last Post: 03-29-2015, 12:24 PM
  3. Storing and sharing database on slow server
    By kagoodwin13 in forum Access
    Replies: 5
    Last Post: 06-04-2012, 12:08 PM
  4. Storing PDF file in Access
    By RANCHLAW56 in forum Access
    Replies: 2
    Last Post: 01-02-2011, 05:36 PM
  5. How would you output an XML file with an Ole Attachment?
    By techneophyte in forum Programming
    Replies: 7
    Last Post: 09-09-2010, 09:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums