473,545 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Insert copied records using MS Access


I've been using MS Access as a front end to our remote MySQL db for a
long time.
I've just added a facility for clients to select a record to copy along
with all its sub-records.

The initial record copies accross ok, but I seem to be having a spot of
bother getting the sql syntax to work. I keep getting an ODBC error
3146 ?

_______________ ____

Here is some of the code I have .......... which works fine with an MS
Access back-end but not MySQL

code ...............

Dim MySql1 As String
Dim MySql2 As String
Dim MySql3 As String
Dim MySql4 As String
Dim MySql5 As String
Dim MySql6 As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = DBEngine(0)(0)
'Set db = CurrentDb

NewProductCode = DMax("product_I D", "products")

'------------------ COPY RELATED PRODUCTS OVER
------------ perhaps it is failing because no line ID is being created
for each record of the related table ??
''''' Grab next related ID ......... trying to test various ideas .....

NewRel = 1 + DMax("related_I D", "Related")
MySql1 = "INSERT INTO Related (product_ID, product_Ref,
prod_relate) "
MySql1 = MySql1 & "SELECT " & NewProductCode & " as NewProductID,
Related.product _Ref, Related.prod_re late FROM Related "
MySql1 = MySql1 & "WHERE Related.product _ID = " & currentid
db.Execute MySql1, dbFailOnError

This code keeps failing with error 3146 on the db.Execute line ........
i'm stumped, but seriously need to get this working soon....

Appreciate any help you can offer.



Jul 13 '06 #1
0 2307

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: shank | last post by:
I have a recordset that contains multiple records of product a user is purchasing. For clarity, I converted the recordset fields to variables. I need to take that entire recordset and insert it into another table on a remote server. The below code only inserts 1 record. How do I change the code to get all records inserted? thanks! <% Dim...
by: J.D. Buehls | last post by:
I have an .asp page with a form to copy job responsibilites form one job to another. It is a hotmail type interface with checkboxes besides each responsibility. After submitting, it should copy the selected resp's to a different job. After that it should renumber that job's responsibilities. This is the code I am using now to copy:...
by: Paul Shaw | last post by:
Can anyone explain why an insert might cause multiple logical bufferpool data reads? Here's a situation that has me scratching my head. Table A's data resides in tablespace B Table A's indexes reside in tablespace C Table A has no long data No other data resides in either of these tablespaces.
by: ImraneA | last post by:
Hi there I had pleasure of upsizing Access v97 db to Access v2K/SQL 2K. Wish to provide some knowledge gained back to community - hopefully help others. 1.Question how do you test stored procedure from SQL Server vs MS Access point of view ?
by: Bob Alston | last post by:
I have a routine to copy data to new versions of my app via insert into sql statements. Unfortunately, due to evolution of my app, sometimes the new version has more restrictive editing than an older version that I am updating. Thus I get this message. It tells me only how many records have errors, not which errors or which records. ...
by: jking482 | last post by:
I am using Access 2000. I am using INSERT INTO syntax that works most of the time, but sometimes it doesn't insert the record. The data base has been heavily used for five or more years now. There have been many deletions of records and additions in that time. The AutoNumber field is past 6 digits. It is long integer data type. My theory...
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am using MS-Access 2000 database table for this app. Note that the datatype of all the fields mentioned above are Text. Apart from the above columns,...
by: MLH | last post by:
Suppose, in a multi-user environment, you have append query SQL in a VBA procedure that looks like INSERT INTO MyTable... and the next line reads MyVar=DMax("","MyTable... You can never be certain that MyVar will be set to the key-field value that was created when the Append query ran. Now, there are other ways to do it - I know - that...
by: EJO | last post by:
with sql 2000 enterprise Trying to build a stored procedure that will take the rows of a parent table, insert them into another table as well as the rows from a child table to insert into another table and be able to maintain the relationships between the parent/child rows of the new records. Something like old_id new_id
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...
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. ...
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...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
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...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.