Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Creating copy of attached file on new location (2003)

    I have some issues with users inserting attachments from their personal computer and from a server location and some users can see the attachment that was created on some users personal computer folder.
    Is there a way I can have on the search prompt when looking to insert an attachent to make a copy of the file into a central location on a server folder and make/save the link to the new copy instead of the previous location of the file. I found this code in the forum can this one be modify:

    Private Sub cmdInsert_Click()
    Dim OFN As OPENFILENAME
    On Error GoTo Err_cmdInsert_Click

    ' Set options for dialog box.
    With OFN
    .lpstrTitle = "Files"
    If Not IsNull([Attachment]) Then .lpstrFile = [Attachment]
    .flags = &H1804 ' OFN_FileMustExist + OFN_PathMustExist + OFN_HideReadOnly
    .lpstrFilter = MakeFilterString("All files (*.*)", "*.*")
    End With

    If OpenDialog(OFN) Then
    [Attachment] = OFN.lpstrFile
    SysCmd acSysCmdSetStatus, "Afbeelding: '" & [Attachment] & "'."
    End If
    Exit Sub

    Err_cmdInsert_Click:
    MsgBox Err.Description, vbExclamation

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Creating copy of attached file on new location (2003)

    If different users select the same file name it might become problematic, but you could try something like this:

    Dim intPos As Integer
    Dim strName As String
    ' Path to central location, must end in backslash
    Const strServerPath = "serversharefolder1folder2"

    If OpenDialog(OFN) Then
    intPos = InStrRev(OFN.lpstrFile, "")
    strName = Mid(OFN.lpstrFile, intPos + 1)
    FileCopy OFN.lpstrFile, strServerPath & strName
    [Attachment] = strServerPath & strName
    SysCmd acSysCmdSetStatus, "Picture: '" & [Attachment] & "'."
    End If

  3. #3
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Creating copy of attached file on new location (2003)

    Hans the code works great, I just added
    Dim OFN As OPENFILENAME so it can work with the module that you provided in a previous post.

    Have another question, I am trying to open the document from the loation provided. I changed the field [attachment] in the table to be a hyperlink field so I can follow the address but it doesnt work. Do you know why is that.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Creating copy of attached file on new location (2003)

    When you convert a text field to a Hyperlink field, Access probably inserted http:// in front of the path. I have no time right now to think about a solution, I'll get back to it later.

  5. #5
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Creating copy of attached file on new location (2003)

    not a problem..thanks for all the help. I will search some other post to see what I can find, and post any answer to this one. I think I found it

    I made the field back to a text field instead of hyperlink and inserted the following code in the On DblClick procedure

    Application.FollowHyperlink Me.Attachment

    It works like a champ....Thank Hans

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •