473,386 Members | 1,793 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,386 software developers and data experts.

Trouble with Append Query

I can't figure this out...

I'm in Windows XP with Access 2007. I have this code in my form's class module...

Expand|Select|Wrap|Line Numbers
  1. mySql = "INSERT INTO mtb_PartWordsSavedDetail ( PartWordsSavedHeadID, PartWords )"
  2.        mySql = mySql & " SELECT CLng(" & Me!PartWordsSavedHeadID & ") AS [HeadID], mtb_PartWordsTemp.PartWordTemp"
  3.        mySql = mySql & " FROM mtb_PartWordsTemp"
  4.        mySql = mySql & " WHERE mtb_PartWordsTemp.PartWordsBox=" & PartBox & ";"
  5.        Debug.Print mySql
  6.  
  7.        DoCmd.RunSQL mySql
  8.  
When I run it through the form, my table does not update, but the immediate window does produce the final Sql in mySql:

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO mtb_PartWordsSavedDetail ( PartWordsSavedHeadID, PartWords ) SELECT CLng(16) AS [HeadID], mtb_PartWordsTemp.PartWordTemp FROM mtb_PartWordsTemp WHERE mtb_PartWordsTemp.PartWordsBox=1;
  2.  
When I copy and paste the above SQL into a query, it runs fine and the table updates.

I feel the problem has something to do with the [HeadID] getting converted into a string by the &'s. I tried using the CLng function to convert to a long integer. Again, the Sql updates the table correctly when I run it through a query, but it will not work in the module.

Can anyone help?
Thanks,
Adam
Sep 24 '09 #1
1 1406
NeoPa
32,556 Expert Mod 16PB
Is it possible that the table is locked when the form is open? Perhaps the form is bound to that table.

Try running the SQL as a query immediately before it executes line #7 of your code.

You will need to stop the code at that point. See Debugging in VBA for help on stopping the code.
Sep 24 '09 #2

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

Similar topics

2
by: John | last post by:
Hi - I am trying to perform a simple append query, with no luck. I have a table (MktPrices) that has the following fields: BondID, PriceDate, Price. The objective is to allow the user to input a...
2
by: Danny | last post by:
I want to extract a subset of fields from one table into another the master table has many fields the subset has about half, but still many. Is there a way I can just append the master into the...
1
by: Aaron | last post by:
Hello fellow programmers, I am trying to run an append/update query from code, a command button on a form initiates the queries. the format i am using is; ...
1
by: David Barger | last post by:
Greetings, It appears that an Append Query I run in Access XP is randomly failing to append a field. I have payroll data being entered into a payroll database. This data is exported daily to...
4
by: robboll | last post by:
When I try to use an append query from an oracle link it takes forever. I am exploring the idea of doing an append action using a pass-through query. If I have an Oracle ODBC connection to...
0
by: harry12 | last post by:
Hello- I'm fairly new at using Microsoft Access and I'm having trouble getting a couple of things to work in my database. The first is that I have yet to find a way to get an append query to...
4
by: pmacdiddie | last post by:
I have an append query that needs to run every time a line item is added to a subform. The append writes to a table that is the source for a pull down box. Problem is that it takes 5 seconds to...
2
by: Roshawn | last post by:
Hi, On my asp.net page I have an html form. I've set runat attribute to server and filled it with server controls. All settings are as I like them. So here's the problem: when I perform a...
10
by: pythonnoob | last post by:
Hello everyone. New to python as well as this forum, but i must say ive learned a but already reading through some posts. Seems to be a pretty helpful community here. Before i post a question...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
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...

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.