Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBS writing to an Access table

Status
Not open for further replies.

teach314

Technical User
Jul 29, 2011
183
CA
hello to all

I'm VERY new at VBS. The following code gets the names of all the .mdb files in a specified folder, then
writes these names to a file called TEST3.txt. It works perfectly.

What I want to do instead is write the mdb file names to an ACCESS table. (in TEST4.mdb, table tblTEST5)

Could some kind soul show me how to modify the code to do this? Many thanks in advance.

Code:
	Dim fso 
	Dim ObjFolder 
	Dim ObjOutFile 
	Dim ObjFiles 
	Dim ObjFile  

	Set fso = CreateObject("Scripting.FileSystemObject")               'Creating File System Object  
	Set ObjFolder = fso.GetFolder("E:\ARCHIVEa_3")	                   'Getting the Folder Object   
        Set ObjOutFile = fso.CreateTextFile("C:\TEST3.txt"                 'Creating an Output File to write the File Names   
	Set ObjFiles = ObjFolder.Files  				   'Getting the list of Files 

	For Each ObjFile In ObjFiles     				   'Writing Name  to Output File 
		If Right(ObjFile.Name, 4) = ".mdb" then

			ObjOutFile.WriteLine(ObjFile.Name)
			
		End If
	Next  

	ObjOutFile.Close

 
You need to connect to Access using either ODBC or OLEDB. The connection string and version of access are important. Almost anything will connect to an mdb file but only certain versions will connect to accdb files.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top