Results 1 to 6 of 6
  1. #1
    PBCN is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2016
    Posts
    24

    Variables in a Hyperlink

    Im sorry to say but I am very green to VBA but after much reading and things going over my head im still not sure im going about my problem the right way.

    What I have and trying to do is:-

    Im building a access program to manage the admin and job management for a business doing building approvals and inspections, I am already using and plan to run in conjuntion with the access program onedrive to hold all the files, like plans etc and the photos that go along with the inspections. I am planning to have a file location in access and in onedrive for each separate job.

    I am going to use sharepoint as the backend and the program is going to be used on 3-5 different computers.



    I want to be able to put a link or command button on each job file in access to open the onedrive file for that job but it contains two variables that I need to add into the destination line, one being the User of the computer and the other being the file number

    the code so far
    Code:
    Private Sub JobFile_Click()    Dim UserName As String
            UserName = Allan
        Dim JobFile As String
            JobFile = Me![JobFile]
    Application.FollowHyperlink "C:\Users\UserName\OneDrive\PCAwork\jobs\Jobfile"
    End Sub
    I basically want the hyperlink to end up looking something like this C:\Users\Allan\OneDrive\PCA work\Jobs\16-129 Lot 34 Foxtail St Fern Bay

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try

    Application.FollowHyperlink "C:\Users" & UserName & "\OneDrive\PCAwork\jobs" & Jobfile

    I keep editing to add the backslashes that got dropped, and they won't stick. Put them in as appropriate.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    PBCN is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2016
    Posts
    24
    This is what I am now using, I took out the UserName part just to try and get it working with one variable before re-adding the second
    Code:
     Dim JobFile As String        JobFile = Me![JobFile]
    Application.FollowHyperlink "C:\Users\Allan\OneDrive\PCAwork\jobs\" & JobFile
    But Im still getting a run time error 490 cannot open the specified file.

    Could/would the problem be that Im trying to open a file folder and not a file like a PDF?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Not at a computer but try adding a backslash after the folder name.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    PBCN is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2016
    Posts
    24
    Ok after some further tinkering Ive got it working, code below
    Code:
    Private Sub Command310_click()    
        Dim JobFile As String
        Dim strinput As String
        
            JobFile = Me![JobFile]
    
    
            Me.Text306 = "C:\Users\Allan\OneDrive\PCA work\Jobs\" & JobFile
            
            strinput = Me![Text306]
    
    
    Application.FollowHyperlink strinput, , True
    
    
    
    
    End Sub

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Glad you got it working. I note a new space in the path. Welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Hyperlink Variables
    By CCW8 in forum Access
    Replies: 5
    Last Post: 07-08-2013, 06:20 PM
  2. Replies: 4
    Last Post: 01-05-2013, 11:07 AM
  3. VBA variables in SQL
    By compooper in forum Programming
    Replies: 3
    Last Post: 07-06-2011, 11:04 AM
  4. Replies: 4
    Last Post: 01-31-2011, 03:19 PM
  5. VBA in variables
    By smikkelsen in forum Access
    Replies: 3
    Last Post: 11-12-2010, 03:14 PM

Tags for this Thread

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