Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Attaching link to file (A2003)

    Hello All,
    I asked some time ago and can't find the response..... I need to write some code to attach a file name inside my DB. For instance, the user creates a word doc with some information in it. There is a related record in the DB and I want something that allows the user to point to the file, upload it to the server to a set location and put a hyperlink in the db pointing to the file on the server. The end result being is that the user can then click the hyperlink and open the linked file if needed. Has anyone done anything like this before?

    Thanks,
    Mark

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

    Re: Attaching link to file (A2003)

    If you have a hyperlink field in the table, the user can right-click the text box bound to the hyperlink field and select Hyperlink | Edit Hyperlink. If you perefer, you can put a command button next to the text box, with the following On Click code:

    Private Sub cmdLink_Click()
    Me.txtFile.SetFocus
    On Error Resume Next
    RunCommand acCmdInsertHyperlink
    End Sub

    where txtFile is the name of the text box and cmdLink the name of the command button.

  3. #3
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Attaching link to file (A2003)

    Thanks Hans,
    One other thing I need to do is upload a file from a fixed location on the user PC. Can I use some VB code to go find a file with a certain name and copy it to a network location? After that operation, I want to use the hyperlinking that I mentioned in the previous post.

    Thanks,
    Mark

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

    Re: Attaching link to file (A2003)

    If the file is in a fixed location, you don't need to find it, or have I misunderstood? You can use

    FileCopy "C:FolderFile.ext", "ServerShareFolderFile.ext"

    to copy a file from the user's C: drive to a network folder.

  5. #5
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Amersfoort, Utrecht, Netherlands
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Attaching link to file (A2003)

    Hans,

    I want to link more then one file to a record.
    So I created a file that will link to my main table with an ID
    Now I want to make a continious form that shows me all the links of a record.
    That is working.... but I like your solution for changing the hyperlink field by a button

    Is it possible to have a button next to hyperlinkfield?

    >>> OKAY I just sould have tried it before I started asking... it is just working the way you descriped it... great thanks

  6. #6
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Attaching link to file (A2003)

    It's been a while since I looked into this. How do you execute a hyperlink from something like a command button? Or, is it possible to open a folder using a command button?

    Thanks,
    Mark

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

    Re: Attaching link to file (A2003)

    The idea of a hyperlink is that the user only has to click it to execute ot. If you want to simulate this in code, you can use Application.FollowHyperlink, for example

    Application.FollowHyperlink "http://www.wopr.com"

    Of course, you can use a variable instead of a literal string.

    If you want to open a folder, you can use Shell to start an instance of Explorer.exe with the appropriate path.

Posting Permissions

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