Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Visitor Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Follow Server Folder in Access
Chris Lopez 
     
14 months ago
Hello,
I'm trying to access a file on my network server,
I followed the directions in the video How To Add a Button to Open Client-Specific Folders in Microsoft Access.
I still can't get it to work

I get an error Compile Error
Expected: Line number or label or statement or end of statement.

This is the code I have,
Private Sub EmployeeFileBtn_Click()
    
    Dim FilePath As String
    FilePath S:"\Human Resources\Employee Files\" & EmpId & "\"
    
    Shell "explorer.exe " & FilePath, vbNormalFocus
End Sub

S= the network drive that I have mapped to the server drive.

Can anyone assist me in fixing this issue?

Thank you
Richard Rost  @Reply  
          
14 months ago
You're missing an equal sign, and you have the quote in the wrong place after S:

FilePath = "S:\Human Resources\Employee Files\" & EmpId & "\"

And if you have spaces in your path, you should wrap the entire string in double-quotes as well:

FilePath = """S:\Human Resources\Employee Files\" & EmpId & "\"""

See Concatenation and Double Double Quotes.
Chris Lopez OP  @Reply  
     
14 months ago
Ok, now that doesn't give me an error; it takes me to the Documents folder. In the video, I believe you said it would do that if it couldn't find the path. but that is the path,

I'm wondering if the employee file is named incorrectly. The individual employee file name is 0001-Lastname, Firstname.

It has the name, so I can easily determine whose file it is.
Should I change that?
Richard Rost  @Reply  
          
14 months ago
Well it has to match exactly so you're going to have to change the folder or change the path that the database is looking for.
Chris Lopez OP  @Reply  
     
14 months ago
I believe it does match.
The file path is S:\Human Resources\Employee Files\
last,first\0001.

The VBA Code is
Private Sub EmployeeFileBtn_Click()
    
    Dim FilePath As String
    FilePath = """\\S:\Human Resources\Employee Files\Last,first\0001\" & EmpId & "\"""
    
    Shell "explorer.exe " & FilePath, vbNormalFocus
End Sub
Should I change the last,first to just the EmpId?
Richard Rost  @Reply  
          
14 months ago
Yeah, I'd just use ID. And what's with the \\ at the start of the FilePath? That's not valid.
Chris Lopez OP  @Reply  
     
14 months ago
The Drive Letter on the server with the folders is E Drive:. I have the DB on the same drive.

This is the code I have in there now

Private Sub EmployeeFileBtn_Click()
    
    Dim FilePath As String
    
    FilePath = """E:\Human Resources\Employee Files\" & EmpId & "\"""

    Shell "explorer.exe " & FilePath, vbNormalFocus

This is the path to the files on the server to employee Id 1
E:\Human Resources\Employee Files\1

It still opens to the documents folder.
Any Suggestions?
Thanks
Kevin Robertson  @Reply  
          
14 months ago
Verify the full path is valid.

I ran a test on my system with a valid path and it worked perfectly.
I then added a folder to the path that doesn't exist and I was taken to my Documents folder.
Chris Lopez OP  @Reply  
     
14 months ago
Ok, how do I verify the file path? I copied and pasted the path from file explorer.
Sami Shamma  @Reply  
             
14 months ago
Hard code the path you copied into your code and see if it works. Also pay attention to final "/"
Matt Hall  @Reply  
          
14 months ago
You can msgbox or debug.print FilePath in the module to check the contents of FilePath.  Alternatively, put a breakpoint on the shell line in the module and run the code.  When the code stops, hover the mouse over FilePath and see what the value is.
Richard Rost  @Reply  
          
14 months ago
Chris Lopez OP  @Reply  
     
14 months ago
Thanks to everyone that replied,
I dont know what the problem was, but I copied the code to a word doc, deleted the code and copied the exact code back in and it worked perfect. must have been an glitch or something. but its working now.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Visitor Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/20/2026 9:47:39 PM. PLT: 1s