Wrox Programmer Forums
|
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 November 29th, 2005, 07:10 PM
Registered User
 
Join Date: May 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Writing to a table

I am looking to create some code that would write all data from a
DOS directory to an Access table? Any suggestions on how to get started would be appreciated.

Thanks,
 
Old November 30th, 2005, 09:25 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

When you say "all data", what exactly does that mean? All file contents, all file names, etc? What do you want to copy?

mmcdonal
 
Old December 6th, 2005, 06:55 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 155
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to leehambly
Default

Mcd,

You would be far better off learning about the FileSystemObject and using that in code. I used to struggle with limited skill using "dir >c:\dir_listing.txt" type things, and then struggling to translate the output... but when you have mastered the FSO (and there aint much to mastering it) you will wonder why you ever bothered!

Suck eggs part:
You will need to add the "Microsoft Scripting Runtime" to the References in the VBA window. Select Tools --> References and then scroll down til you find "Microsoft Scripting Runtime" and then tick the box and click OK.

Now use something like this...
================================================== ===========
Public Sub psubListFiles(strFolderPath As String)

Dim fso As FileSystemObject
Dim fldFolder As Folder
Dim sfdFolder As Folder
Dim filFile As File

Set fso = New FileSystemObject
Set fldFolder = fso.GetFolder(strFolderPath)

For Each filFile In fldFolder.Files
    Debug.Print fldFolder.Path, filFile.Name
    DoEvents
Next filFile

For Each sfdFolder In fldFolder.SubFolders
    psubListFiles (sfdFolder.Path)
    DoEvents
Next sfdFolder

End Sub
================================================== ===========

You will need to replace the "debug.print..." with whatever you need to use the data, either writing to a table or recordset or whatever.. but should give you a slightly better and more wholesome method for getting this data.

Hope it helps.





Similar Threads
Thread Thread Starter Forum Replies Last Post
help writing dynamic form data to dynamic table ublend SQL Server ASP 1 June 1st, 2007 08:09 AM
help writing dynamic form data to dynamic table ublend Classic ASP Professional 1 June 1st, 2007 08:08 AM
Writing to Database - Please Help Dwizz VB.NET 2002/2003 Basics 12 May 11th, 2005 08:37 AM
size of table (type table is table of number) MikoMax Oracle 1 November 19th, 2003 03:11 AM
Writing to an Oracle table from Excel emad100 Excel VBA 0 October 29th, 2003 10:24 AM





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