VBS – Checking table existence in Access

This code first reads a line from a txt file and checks out its existence in access db. then the results are written to a different txt file


Const ForReading = 1
 Set objFSO = CreateObject("Scripting.FileSystemObject")
 Set objTextFile = objFSO.OpenTextFile("c:\listfile.txt", ForReading)

 Set objTextFileWrite = objFSO.OpenTextFile("c:\listfileTEST.txt", 8, True)

Do Until objTextFile.AtEndOfStream
    strNextLine = objTextFile.Readline
    ''check table existence
    If DCount("[Name]", "MSysObjects", "[Name] = '" & strNextLine & "'") = 1 Then
    ' table exists
   objTextFileWrite.WriteLine ("EXISTS " & strNextLine)
    ' table does no exist
  objTextFileWrite.WriteLine ("DOES NOT EXIST " & strNextLine)

Leave a Reply

Your email address will not be published. Required fields are marked *