Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
VBA File Copy
Glenn Kraniske 
    
4 years ago
Good morning everybody:
I have some VBA code that I copied from Rick's sample database.  It's for a file picker and it works great.  I'm looking to add some more code to it so that when the file is picked, it is copied to a share on the network and the path is stored in the database.  Here's the code I'm using:


Code below...
Private Sub FilePickerBtN_Click()
StoredPath = PickFile("\\WIN-SERVER-001\Attachments")
End Sub
Public Function PickFile(Optional InitialFolder As String = "", _
        Optional IsFolder As Boolean = False, _
        Optional FilenameOnly As Boolean = False) As String

    Dim FO As Object, FSO As Object, PickType As Long
    
    On Error Resume Next
    PickType = IIf(IsFolder, 4, 3)
    Set FO = Application.FileDialog(PickType)
    If InitialFolder <> "" Then
        FO.InitialFileName = InitialFolder
    Else
        FO.InitialFileName = CurrentProject.Path
    End If
    FO.Show
    PickFile = FO.SelectedItems(1)
    
    If FilenameOnly Then
        Set FSO = CreateObject("Scripting.FileSystemObject")
        PickFile = FSO.GetFileName(PickFile)
    End If
End Function

Private Sub StoredPath_DblClick(Cancel As Integer)
ShellExec StoredPath
End Sub

I'm brand new to coding.  What I've learned is mainly from Rick's videos and things I've found on the web.  Thank you all for understanding.  Have a wonderful day.
Adam Schwanz  @Reply  
           
4 years ago
You'll need to store the value in a table field.Then you can use a currentdb.execute statement to set the fields value when you change it.
Adam Schwanz  @Reply  
           
4 years ago
I believe docmd.runsql is covered in developer 15, currentdb.execute does the same thing.
Glenn Kraniske OP  @Reply  
    
4 years ago
That's how I'm doing it.  The attachment gets stored in a network share called "Attachments" and the path is stored in the database.  Based on the code I posted I was wondering is there was some code I could add to it that would copy the file from the location where the file was picked, to the "Attachments" share.
Kevin Robertson  @Reply  
          
4 years ago
Glenn Kraniske OP  @Reply  
    
4 years ago
I'm already using a picture box for photos.  I can browse to a photo and store the path in the DB.  Been looking all over for some code to copy from one location to the "attachments" share but I'm coming up dry.  Frustration is setting in because I know it can be done but I can't seem to find the info.  I purchased one of the courses to get myself this far but I can't keep doing that as frequently as some people can.  Thanks for everyone's help.
Richard Rost  @Reply  
          
4 years ago
Hi Glenn. Kevin pointed you in the right direction. Lessons 13 to 16 of the Imaging Seminar are all about copying files to a central server folder once the user selects them.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer 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/1/2026 12:36:03 AM. PLT: 0s