473,378 Members | 1,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Update table with contents of a directory

lwwhite
16
I'm using Access 2003, Win XP. I want to update a table with the contents of a directory and subdirectories. I have a directory structure like this:

FolderA
Subfolder1
[multiple XML files]
Subfolder2
[multiple XML files]

I want to place each of those XML file names into two fields in a table called tbl_sourcedocs. I'd like to place the path into tbl_sourcedocs.sourcedoc_path and the file name itself into tbl_sourcedocs.sourcedoc_name.

I then want users to be able to select the appropriate file from a list box on a form. If I can get the table built, that part should be straightforward.

Assuming I can get this working, how is the table update triggered? Say a user added a file to the directory then returned to the db...would it automatically be available for selection in the list box? Would the user have to manually trigger some table update event?

I'm not a programmer, so I need very detailed instructions. Actual code would be much appreciated, if possible :)

Thanks for any help.
Dec 3 '06 #1
1 2009
NeoPa
32,556 Expert Mod 16PB
1. Getting the file system information within VBA.
You can use the Dir() function. It only returns one item at a time so you will need to code it to get all the relevant files and directories. I've quoted the first part of the Dir() Help page.
Dir Function


Returns a String representing the name of a file, directory, or folder that matches a specified pattern or file attribute, or the volume label of a drive.

Syntax

Dir[(pathname[, attributes])]

The Dir function syntax has these parts:

Part Description
pathname Optional. String expression that specifies a file name — may include directory or folder, and drive. A zero-length string ("") is returned if pathname is not found.
attributes Optional. Constant or numeric expression, whose sum specifies file attributes. If omitted, returns files that match pathname but have no attributes.



Settings

The attributes argument settings are:

Constant Value Description
vbNormal 0 (Default) Specifies files with no attributes.
vbReadOnly 1 Specifies read-only files in addition to files with no attributes.
vbHidden 2 Specifies hidden files in addition to files with no attributes.
VbSystem 4 Specifies system files in addition to files with no attributes. Not available on the Macintosh.
vbVolume 8 Specifies volume label; if any other attributed is specified, vbVolume is ignored. Not available on the Macintosh.
vbDirectory 16 Specifies directories or folders in addition to files with no attributes.
vbAlias 64 Specified file name is an alias. Available only on the Macintosh.
2. Triggering the updates of the table in the database.
I think this may well have to be a command button selected by the user. You would need to code it to do a recordset.Requery. You could always add the same code into an event procedure but it wouldn't be able to synchronise exactly with your update.
3. Doing all the coding for you.
Sorry, not the idea to my mind. I'll happily answer questions I can but am a little suspicious of such requests so avoid acquiescing :(.
If you're not very comfortable coding then it's time to learn. This we can and will help with, as well as answering questions along the way.
Dec 4 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: PAUL EDWARDS | last post by:
I have a windows form that is bound to a datatable. In VB6 I could just update the field contents and it would be updated in the database, however if I update the text property of the control from...
1
by: Mike L. Bell | last post by:
Query: update table1 t1 set end_time = ( select end_time from table2 t2 where t2.key1 = t1.key1 and t2.key2 = t1.key2 ) where exists
2
by: Mark Reed | last post by:
Hi all, I don't know if this is do-able but you never know until you ask. A situation at work has arisen where I have to trawl through over 500 text files, copy the contents and then paste them...
2
by: Chris Fink | last post by:
Any idea why the database table is not being updated with the contents of the excel file loaded into the dataset? Any help is appreciated! // load database table, shell only string cnString =...
4
by: Kevin Cloutier | last post by:
Hi, I wrote a simple script utilizing readdir() to read the contents of a directory, then of all subdirectories and thier contents and echo the filenames to the page. But, here is the...
8
by: Ornette | last post by:
Hello, I have a stored procedure which generates some values in the table. When I use update() how to populate the dataset with theses values ? For the moment I use output parameter but it...
7
by: Mariusf | last post by:
I am a novice Perl programmer and need to change a perl script that I use to create web pages with thumbnail images and some text. Currently the script created a web page for each artist / category...
0
by: mwenz | last post by:
I am trying to update an Access table using OLEDB in VB.Net 2005. I can add rows but I cannot update them. Code to instantiate the Access database and table... Dim conn As New...
2
by: hotflash | last post by:
Hi Master CroCrew, I found a good PURE ASP that will allow you to upload 10MB file to the server and the file contents such as Network, Author, Title, etc... will insert to MS Access at the same...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.