Results 1 to 8 of 8
  1. #1
    jobbie is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2014
    Posts
    46

    Update hyperlink path

    I had created an access database to store path names of files on my local drive using the below vba code:

    Dim rst As dao.Recordset



    Set rst = MyDB.OpenRecordset("MyTable", dbOpenDynaset, dbAppendOnly)

    With rst
    . AddNew
    ! [File_path] ="Link" & "#c:\myfiles#"
    .Update

    rst.Close


    I have only mentioned the code relevant to my question and have left out the other details. The code works fine and I have updated more than 2000 records using it but now I want to change the path of the hyperlink from "#c:\myfiles#" to "#c:\thosefiles#"
    How do I do so?

    Thanks

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    It's tempting to say just modify the !filepath line accordingly but of course you're simplifying to help readers

    However, in trying to be helpful, you've removed too much info to give a sensible answer
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    jobbie is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2014
    Posts
    46
    Quote Originally Posted by ridders52 View Post
    It's tempting to say just modify the !filepath line accordingly but of course you're simplifying to help readers

    However, in trying to be helpful, you've removed too much info to give a sensible answer
    Thanks for your reply but honestly it's really a simple question. I just want to know how can I replace "my files" with "thosefiles" in the path for those 2000 records? I had used a textbox to input data and then used a loop to update the rows in the table based on certain criteria. I am unable to post the entire code because my office computer has internet blocked. I am typing this message from my mobile phone. I can't update the records through access manually because the table displays "Link" instead of the file name.

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    It would be a simple question ... once your meaning is clear to anyone else

    I just want to know how can I replace "my files" with "thosefiles" in the path for those 2000 records?
    Surely you don't really mean this which is how both posts read:
    Code:
    ![File_path] ="Link" & "#c:\thosefiles#"
    I can't update the records through access manually because the table displays "Link" instead of the file name.
    Please explain why that is the case. If you are using lookups at table level, that's a bad idea as it obscures the real data

    My solution would be to use a text field to hold the link path instead of a hyperlink field
    Then you would just reference the path in your recordset line
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    jobbie is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2014
    Posts
    46
    Surely you don't really mean this which is how both posts read:
    Code:
    ![File_path] ="Link" & "#c:\thosefiles#"
    Yes that's correct

    Please explain why that is the case. If you are using lookups at table level, that's a bad idea as it obscures the real data

    My solution would be to use a text field to hold the link path instead of a hyperlink field
    Then you would just reference the path in your recordset line[/QUOTE]

    I wanted a link instead of the path name to be displayed because I have another form which would allow users to click on the link to take them to the file. Now I just want to change the path name of all the files.

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    Ok it's your database and not mine.
    Suggest you do a backup first in case I've misunderstood you....

    Then use this code
    Code:
    ![file_path]=Replace([file_path],"my files","thosefiles")
    Or scrap all your code and use an update query which will be MUCH faster
    In the update to row of the file path field enter the Replace code above

    Note that you wrote myfiles without a space in post 1 but added a space in post 3. Use whichever is correct.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #7
    jobbie is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Apr 2014
    Posts
    46
    Quote Originally Posted by ridders52 View Post
    Ok it's your database and not mine.
    Suggest you do a backup first in case I've misunderstood you....

    Then use this code
    Code:
    ![file_path]=Replace([file_path],"my files","thosefiles")
    Or scrap all your code and use an update query which will be MUCH faster
    In the update to row of the file path field enter the Replace code above

    Note that you wrote myfiles without a space in post 1 but added a space in post 3. Use whichever is correct.
    Thanks it worked!

  8. #8
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    Excellent.
    For future reference, update queries are always faster than looping through recordsets one record at a time.
    If you have many records, the difference can be dramatic.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Replies: 2
    Last Post: 05-30-2017, 05:16 PM
  2. Replies: 4
    Last Post: 07-21-2015, 11:17 AM
  3. Default path for Insert hyperlink code
    By jaworski_m in forum Programming
    Replies: 3
    Last Post: 02-13-2015, 10:42 AM
  4. Insert hyperlink - ensure absolute path
    By jaworski_m in forum Programming
    Replies: 1
    Last Post: 02-04-2015, 11:39 AM
  5. Replies: 5
    Last Post: 10-28-2013, 08: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