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 8726231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:12:25+00:00 2026-06-13T08:12:25+00:00

I am working on an access 2010 database and needs some help. I am

  • 0

I am working on an access 2010 database and needs some help.

I am trying to create some vba code that will run a query and then create and populate a table based on the records returned. I then want to rename the table based on a value from the query (company name).

I have the query built that will return distinct values from my table, but I need to create a seperate table for each company that is returned in the results.

Any and all suggestions are appreciated.

  • 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-06-13T08:12:26+00:00Added an answer on June 13, 2026 at 8:12 am

    Are you sure that it is a good idea to create a different table for every company? I would not reccommend that!

    Okay let’s say that you have your query, named QUERY, that contains the field CompanyName and contains all of the records. You could start with something like this:

    Sub Export_Query()
      Dim rs As Recordset
    
      Set rs = CurrentDb.OpenRecordset("select distinct CompanyName from QUERY")
      While Not rs.EOF
        On Error Resume Next
        CurrentDb.Execute "DROP TABLE [" & rs("CompanyName") & "]"
        CurrentDb.Execute "SELECT QUERY.* INTO [" & rs("CompanyName") & "] FROM QUERY WHERE CompanyName=""" & rs("CompanyName") & """;"
        On Error GoTo 0
        rs.MoveNext
      Wend
    
      rs.Close
      Set rs = Nothing
    End Sub
    

    This is just an idea… you should add more error checking code, and you should also escape company name or make sure it doesn’t contain any special character.

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

Sidebar

Related Questions

I am working on my first Access 2010 database and have run into a
I am working in Access 2010. I am building a database that lets my
I am working on a new application that uses a jet (MS Access) database.
I'm working with VBA in Access 2010 and I have an odd problem. I'm
I’m working with Access 2010. I’m developing a database for a public art program
I have a Access 2003 database that will dynamically load MDB databases as a
Just a little background: I am using Access 2010 to create forms and VBA
I have the following SQL query that I am trying to run inside Microsoft
I'm working on managing access for users to some pages on my site. I
I am working on an Access adp that has its data stored in sql-server.

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.