I am attempting to load from text files, queries into an MS Access Queries Collection using VBScript. I am using something like this: The code originated from Here.
for each myFile in folder.Files
objecttype = fso.GetExtensionName(myFile.Name)
objectname = fso.GetBaseName(myFile.Name)
WScript.Echo " " & objectname & " (" & objecttype & ")"
if (objecttype = "form") then
oApplication.LoadFromText acForm, objectname, myFile.Path
elseif (objecttype = "bas") then
oApplication.LoadFromText acModule, objectname, myFile.Path
elseif (objecttype = "mac") then
oApplication.LoadFromText acMacro, objectname, myFile.Path
elseif (objecttype = "report") then
oApplication.LoadFromText acReport, objectname, myFile.Path
elseif (objecttype = "sql") then
'oApplication.LoadFromText acQuery, objectname, myFile.Path
' Add create querydef code here
end if
next
But I am unsure how to create a query definition using VBScript.
Any ideas?
Note: I originally Exported to the file using something like this:
For Each myObj In oApplication.CurrentDb.QueryDefs
Set f = fso.CreateTextFile(sExportpath & "\" & myObj.Name & ".sql", True)
f.WriteLine(myObj.SQL)
f.Close
Next