473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

VBA Access problem with RunSQL

175 100+
I'm trying to copy part of one table into another (using a VBA macro), and I keep getting the error message

'3127' INSERT INTO contains the following unkown field...

...the reason I'm confused is that the field names are IDENTICAL. Plus, I've used this code for a few months and never had a problem, until I tried to add what I have to a different database ( but both databases have the EXACT same field names )

if anyone can help I would appreciate it.

this is the code...don't know whether or not it will help...
Expand|Select|Wrap|Line Numbers
  1.  
  2. objAccess.DoCmd.RunSQL "INSERT INTO Y    SELECT *   FROM X;"
  3. objAccess.DoCmd.RunSQL "DROP TABLE X;"
  4.  
  5.  
Apr 30 '07 #1
3 1935
Rabbit
12,516 Expert Mod 8TB
Well, what are the unknown fields?
Apr 30 '07 #2
MMcCarthy
14,534 Expert Mod 8TB
I'm trying to copy part of one table into another (using a VBA macro), and I keep getting the error message

'3127' INSERT INTO contains the following unkown field...

...the reason I'm confused is that the field names are IDENTICAL. Plus, I've used this code for a few months and never had a problem, until I tried to add what I have to a different database ( but both databases have the EXACT same field names )

if anyone can help I would appreciate it.

this is the code...don't know whether or not it will help...
Expand|Select|Wrap|Line Numbers
  1.  
  2. objAccess.DoCmd.RunSQL "INSERT INTO Y    SELECT *   FROM X;"
  3. objAccess.DoCmd.RunSQL "DROP TABLE X;"
  4.  
  5.  
There are two ways to do an insert statement ...

Expand|Select|Wrap|Line Numbers
  1.  INSERT INTO [tableA] ([column1], [column2], [column3])
  2. VALUES ('value1', #value2#, value3);
OR
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO [tableA] ([column1], [column2], [column3])
  2. SELECT [column1], [column2], [column3] FROM TableB;
May 1 '07 #3
NeoPa
32,556 Expert Mod 16PB
The point here being that your SQL was not of the right syntax.
May 3 '07 #4

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

Similar topics

1
by: Tom Lee | last post by:
Hi Guys, Firstly thanks for all the help you have providing me... I have another question I was stuck with. Here is a simple code dim strsql as string dim scr as recordset
7
by: TSanders | last post by:
Wize ones: I created an Access database for a local telco that is split into a front and back end. I would like to distribute the Access runtime along with the front end. When I use the front...
16
by: RichardP | last post by:
Hi there everyone - I'm new to this forum. I am having an issue when running an application from an instance of Access which has been started through automation (early or late bound, makes no...
10
by: Walshi | last post by:
Hi all, I'm a relative newby to access and VBA etc. My forms and tables etc are working great and saving lots of time...However... I have two databases with the exact same table format. I want...
13
by: NDayave | last post by:
How do, For backing up my database(Access 2000), i am trying to just back up the tables and their data, as this will save on space and allow for importing back into the actual database. I want the...
6
by: cyndithomas via AccessMonster.com | last post by:
I new to Visual Basic and am struck on a issue. Have created a Login in Screen for Remote User to access and input data. Want the Remote to be able to login & access the Input Form, and Manager...
3
by: Kalaine | last post by:
Access 2003: The following code is intended to delete the current record and all child records but results in an error, help please, thx. Private Sub CmdDelBSR_Click() On Error GoTo...
4
by: The.Daryl.Lu | last post by:
Hi, Have a bit of a problem... I've created a form in Access and will use the form for a user to query a table based on the selected fields. The problem lies in that I was using checkboxes for...
15
by: OfficeDummy | last post by:
Hello all! I searched the Internet and this forum for a similar problem, but I found no help... Also, I'm a complete newbie to the fascinating world of programming, VBA and Access, so my question...
3
by: masonic35and7 | last post by:
I work for a school district, and I have just imported 6 Excel worksheets into Access 2007. Now I have 6 different tables. In each table all the fields are the same. I need the easiest way to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.