Page 2 of 4 FirstFirst 1234 LastLast
Results 16 to 30 of 48
  1. #16
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234
    EventID is a field in form frmEvent. The Event ID is part of the name of the folder that is opened when the command button is clicked.

    However, there are a few events that don't have a folder yet, so instead of looking for a folder that doesn't exist, I want it to open the containing folder if it can't find the specific folder with [Me.EventID] as the name.

    For example, if I'm looking at event 18931, then Me.EventID is 18931. When I click on the command button, it will open the folder \\SPARE\SharedDocs\Rob's Valet Docs\Valet Proposals\18931.



    If folder 18931 doesn't exist, I'm getting the error message of "Cannot find specified file." Instead, I want it to open \\SPARE\SharedDocs\Rob's Valet Docs\Valet Proposals\ - the parent folder.

  2. #17
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Did you try suggested code?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #18
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234
    Yes. Still got the "cannot find specified file" error.

  4. #19
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    It's not opening the parent folder? Try removing the ending \.

    Did you try code to open file or folder at C:\ root level? If that works then you know the issue is with network, perhaps permissions.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #20
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234
    It is already looking for it at the root level. \\SPARE\Shared Docs is the root location. It's located in the shared docs folder of the network hub computer, named "SPARE". It's not on my hard drive, so I can't make it look at C:\.

  6. #21
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    I am suggesting you do a test that looks at the root on your local computer, not the server. Put a file or folder there and try to open it with code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #22
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234
    I changed it to look for the folder C:\Users\Administrator\Documents, and still got the error message. Don't know if this is relevant, but when I open the debugger, it's highlighting the first line of code instead of the line that seems to matter.

    Click image for larger version. 

Name:	VBA.png 
Views:	8 
Size:	11.0 KB 
ID:	21672

  8. #23
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    I did say back in post 11 that I had issues with FollowHyperlink and instead use Shell.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #24
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234
    Also, not sure when this change happened, but the error message now says "Cannot open the specified file" instead of "Cannot find the specified file."

  10. #25
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Why are you trying to open folder before testing if EventID is Null or if folder exists?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #26
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234
    Quote Originally Posted by June7 View Post
    I did say back in post 11 that I had issues with FollowHyperlink and instead use Shell.
    Yes you did, I'll give that a try now. However, when reading the Shell code, I don't see where it's telling it to look for a specific folder.

    Also, I don't have a problem with a generic error message popping up if an event doesn't have a folder just yet. I tried making it If dir(\\SPARE\...) = "" then
    MsgBox "No folder for this event."

    Still got the "cannot open specified file" error.

  12. #27
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234
    Quote Originally Posted by June7 View Post
    Why are you trying to open folder before testing if EventID is Null or if file exists?
    Is that the problem? Do I just have everything in the wrong order?

  13. #28
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234
    Ok, I changed it around, same problem. I'm ready to give up on this enterprise and go with Shell.

    Click image for larger version. 

Name:	VBA 2.png 
Views:	8 
Size:	11.0 KB 
ID:	21673

  14. #29
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Think about it logically. A folder cannot be opened if it doesn't exist. This will cause runtime error.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #30
    bradp1979 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Location
    San Francisco, CA
    Posts
    234
    So then is this the right order:

    Private Sub Command599_Click()
    Application.FollowHyperlink "\\SPARE\SharedDocs\Rob's Valet Docs\Valet Proposals" & Me.EventID
    If Dir("\\SPARE\SharedDocs\Rob's Valet Docs\Valet Proposals\" & Me.EventID) = "" Then
    Application.FollowHyperlink "\\SPARE\SharedDocs\Rob's Valet Docs\Valet Proposals"
    Else
    If (IsNull(Me.EventID)) Then
    Application.FollowHyperlink "\\SPARE\SharedDocs\Rob's Valet Docs\Valet Proposals"
    Else
    Application.FollowHyperlink "\\SPARE\SharedDocs\Rob's Valet Docs\Valet Proposals" & Me.EventID


    End If
    End If
    End Sub

    If not, what would be the right order?

Page 2 of 4 FirstFirst 1234 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Open an attachment using a command button
    By Eddy Sincere in forum Forms
    Replies: 3
    Last Post: 04-03-2015, 11:43 AM
  2. External script to call Command Button Click event handler
    By Sean Nakasone in forum Programming
    Replies: 5
    Last Post: 10-29-2014, 12:35 PM
  3. Command button open url
    By patrickmcdiver in forum Programming
    Replies: 2
    Last Post: 03-06-2012, 11:08 AM
  4. Command button to open Report
    By swagger18 in forum Programming
    Replies: 0
    Last Post: 11-17-2011, 02:56 AM
  5. Use a command button to open a form
    By johnpaul in forum Forms
    Replies: 24
    Last Post: 09-23-2010, 12:29 PM

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