473,526 Members | 3,177 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Make table query via vba

1 New Member
I have a make table query that I want to run from VBA. What is the syntax to add or change the table name?

Thanks for any help!
Mar 26 '09 #1
2 8933
DonRayner
489 Recognized Expert Contributor
When in query design select (View - SQL View) from the menu bar and copy the sql text. Paste this into your vba, it will be something like this.

Expand|Select|Wrap|Line Numbers
  1. SELECT YourOldTable.* INTO YourNewTable
  2. FROM YourOldTable;
You then need to convert this into a string to run the sql from vba

Expand|Select|Wrap|Line Numbers
  1. Dim stSQL, YourNewTable
  2. YourNewTable = "???????"
  3. stSQL = "SELECT YourOldTable.* INTO " & YourNewTable & " FROM YourOldTable;"
  4. DoCmd.RunSQL stSQL
The YourOldTable would be replaced by whatever your source table is and the YourNewTable would be a string variable variable that you set with the name of the table you wish to create.
Mar 27 '09 #2
NeoPa
32,561 Recognized Expert Moderator MVP
The table name within an Access QueryDef is part of the design and cannot be changed when running the query from code.

A change to the design would be required.

Alternatively, you can get the SQL from the saved QueryDef into a string and modify that string in VBA, then execute that string as SQL as Don has in line #4 of his VBA code.

Welcome to Bytes!
Apr 4 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3061
by: PMB | last post by:
Thank you in advance for any and all assistance. I'm trying to use a make table query to pull the last transactionID, so I can use an append query to reset the transactionID to the next sequential number. My problem is, the make table query is taking all the TransactionID's and putting them in the new table. Is there a way to take the...
4
2376
by: Oreo Bomb | last post by:
I have a secured database that contains a Read-Only group. This group has permissions to view reports, but cannot add, edit, or delete any DB objects. One of the reports the group needs access to is generated with a Make-Table Query. Since the Make-Table Query deletes the previous table it created everytime it's ran, this poses a problem...
2
8600
by: Kathy Krizl | last post by:
I'm probably doing something stupid, but I have a make table query. One of the tables I reference has some check box fields in it. Their Data Type is Yes/No, their field property format is Yes/No, they have no default value, and their Display Control is Check Box. When I run my make table query, the new fields have a Yes/No Data Type, but...
0
1810
by: LesM | last post by:
This is a change of behaviour between Access 2000 SP3 and Access 2002 SP3. I have Progress table that is linked via ODBC into Access using OpenLink Lite for Progress 9.0b. For over a year, using Access 2000 under Win98, I have been running a Make Table or Append query against this ODBC table and producing an extracted Access table. Any...
3
2732
by: Hanif Merali | last post by:
Hello, I'm having some difficulties creating a make table query. The source table which I'm basing the make table query has the fields: CIF BusLine1-2001 BusLine1-2002 BusLine1-2003 BusLine1-2004
7
5079
by: rednexgfx_k | last post by:
All, Problem Summary: I've running about 30 make table queries via VBA in Access 2000, and my database goes from 14,000k to over 2,000,000k. In addition, the longer the procedure runs, the bigger the performance hit VBA takes. I'm wondering how to prevent or reduce this. Details: I have a database table of queries I want to run. This...
24
41542
by: Bob Alston | last post by:
Anyone know a way to make all access to a linked table, in another Access MDB, read only? I really don't want all the hassle of implementing full access security. I can't do this at the server file system because in some front ends the user needs update access. I want to give users access to the data for reporting with their own...
1
2523
by: danijela.simunovic | last post by:
Hi! Is there a way that when I run a "make table query" and an "append query" that i won't be asked those 2 or 3 questions from access like :"you are about to run a make table...","the existing table ABCDE will be deleated..." and so on prompting for yes or no! I would like to make a command button which would prompt me for yes or no and...
4
12317
by: ken | last post by:
Hi, I use this command to run a make table query without opening it... CurrentDb.Execute "make table query name" Access tells me that it can't execute a select query...? Its a make table query not a select? Or are those two the same. Bottom line is that the DoCmd.OpenQuery alowes the user to see the query and I don't want that... ...
3
3460
by: Robertf987 | last post by:
Hi, I'm a bit stuck with an access database. I'm using access 2000 if that's any help. Right, it's 3:40am right now and I'm rather tired, but I *hope* this makes sense. I have a table which contains the main data of the database, records of information of grants. For each financial year, the old data needs taking out of the table. Basically I...
0
7328
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7251
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7474
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7646
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7231
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7600
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5173
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
887
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
545
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.