Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
| Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 14th, 2005, 02:55 PM
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default Storing a file patch from a common dialog box

Hello,

I am really lost, I am trying to think of a way I can make a user click a button and then basically a folder will open up and the user can select any file. When they select the file the path of that file will be saved in a textbox. Any ideas. Thanks

Martin

 
Old March 15th, 2005, 09:38 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

   I needed to do this very same thing. The way I did it was to start by capturing the file names on a particular path, then loading those to a temporary table, then opening a continuous form, and having a button next to each file name for them to select the value and push it to the table or text box.

   Here is how I started:

On the form, I put a button to list files, and then used this code on the button's On Click event:

'=====
Private Sub Command0_Click()

    Dim filesys As Variant
    Dim demofolder As Variant
    Dim fil As Variant
    Dim filecoll As Variant
    Dim filist As Variant
    Dim rs As Recordset
    Dim db As Database
    Dim stFirstName As String
    Dim stLastName As String
    Dim stName As String
    Dim stDocName As String
    Dim stLinkCriteria As String
    Dim stSSN As String

    Set db = CurrentDb()
    Set rs = db.OpenRecordset("tblLocalFile", dbOpenDynaset)

    Set filesys = CreateObject("Scripting.FileSystemObject")

    Set demofolder = filesys.GetFolder("I:\EnvHealth\ACCESS\Data\Scanne dDocuments")

    Set filecoll = demofolder.Files

    For Each fil In filecoll
            rs.AddNew
            rs!LocalFile = fil.Name
            rs.Update
    Next

    stDocName = "frmLocalFileList"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub
'=====

   The form frmLocalFileList was a continuous form based on the table tblLocalFile, and next to the text box in the continuous form I put another button. Unfortuantely I never got as far as inserting the data from this field, but another poster may get you that far. I ended up automatically associating files to records using a foreign key table so that more than one file could be associated with the patient, in this case.

   If you are putting these file associations in NEW records (for example in a linked table,) then repost and I will show you that code modified to take the manual selection. Remind me that we will want to add code in that process to dump the contents of the temp table (tblLocalFile) after the update to prevent dupes.

HTH


mmcdonal
 
Old March 16th, 2005, 03:58 PM
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks thats a great idea, gonna work on it now





Similar Threads
Thread Thread Starter Forum Replies Last Post
coding problem in common dialog box cancertropica Visual Basic 2005 Basics 0 July 30th, 2008 09:38 AM
How to use the flags int common dialog box diegoblin Beginning VB 6 2 November 8th, 2006 03:41 PM
Using common dialog with access azkabancells VB Databases Basics 2 May 14th, 2005 06:01 AM
Instantiating Common Dialog Box Dhodie Pro VB 6 2 July 19th, 2004 04:28 AM
Open File Dialog Box KennethMungwira VB.NET 3 August 3rd, 2003 09:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.