Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 239281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:34:22+00:00 2026-05-11T20:34:22+00:00

I am attempting to load from text files, queries into an MS Access Queries

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:34:22+00:00Added an answer on May 11, 2026 at 8:34 pm

    This saves the query defs

    For i = 0 To db.QueryDefs.Count - 1
        Application.SaveAsText acQuery, db.QueryDefs(i).Name, sExportpath & "\" & db.QueryDefs(i).Name & ".sql"
    Next i
    

    Then the LoadFromText should work

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to load JSON (from php's json_encode) into a Backbone JS collection. I've
I'm attempting to load data from an undocumented API (OsiriX). Getting the NSManagedObject like
I'm attempting to load text files in to a database line by line, I
Im attempting to load a hex literal from an xml settings file, I can
Attempting to use the data series from this example no longer passes the JSONLint
I'm attempting to compile code in a text file to change a value in
I'm attempting to following the tutorials found here: http://www.ifadey.com/2010/06/crud-using-jquery-and-codeigniter/ My code is updated to
OK - I am attempting to load a JSON response (from an external file
I'm attempting to load a file from my hard drive to a file input
I am attempting to load a webpage with file_get_contents(), and am running into problems.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.