473,406 Members | 2,336 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,406 software developers and data experts.

insert into select

i received a runtime error message 3346 when i ran the insert into
select code. i have check to see if the query values and destination
fields are the same and it appears so. atlas, i have no idea why my
insert into query does not work. if anyone has suggestions, it would
be appreciated. thanks in advance.

Set db = DBEngine(0)(0)
Set rst = db.OpenRecordset("ETracking")

If rst.RecordCount > 0 Then
Do While Not rst.EOF
db.Execute " INSERT INTO ETracking " _
& " ([ET Number], [ET LN Shortname], [ET Amount], [ET EC
Code])" _
& " SELECT(Max([ET Number])+1) AS [ET Number] FROM
ETracking), tblImportET.[ET LN Shortname], tblImportET.[ET Amount],
tblImportET.[ET EC Code] " _
& "FROM [tblImportET];"
rst.MoveNext

Loop

End If
Nov 12 '05 #1
4 13467
The syntax of your SELECT is not correct. It looks as if you intend for the
first select column to be a subquery result, but you don't have a SELECT
statement inside the parentheses before the MAX function call.

On 2 Jan 2004 12:21:59 -0800, pi******@yahoo.fr (JMCN) wrote:
i received a runtime error message 3346 when i ran the insert into
select code. i have check to see if the query values and destination
fields are the same and it appears so. atlas, i have no idea why my
insert into query does not work. if anyone has suggestions, it would
be appreciated. thanks in advance.

Set db = DBEngine(0)(0)
Set rst = db.OpenRecordset("ETracking")

If rst.RecordCount > 0 Then
Do While Not rst.EOF
db.Execute " INSERT INTO ETracking " _
& " ([ET Number], [ET LN Shortname], [ET Amount], [ET EC
Code])" _
& " SELECT(Max([ET Number])+1) AS [ET Number] FROM
ETracking), tblImportET.[ET LN Shortname], tblImportET.[ET Amount],
tblImportET.[ET EC Code] " _
& "FROM [tblImportET];"
rst.MoveNext

Loop

End If


Nov 12 '05 #2
Steve Jorgensen <no****@nospam.nospam> wrote in message news:<4f********************************@4ax.com>. ..
The syntax of your SELECT is not correct. It looks as if you intend for the
first select column to be a subquery result, but you don't have a SELECT
statement inside the parentheses before the MAX function call.

i thought the select was my statement that added the new [et number].
thanks for the suggestion !!

jung On 2 Jan 2004 12:21:59 -0800, pi******@yahoo.fr (JMCN) wrote:
i received a runtime error message 3346 when i ran the insert into
select code. i have check to see if the query values and destination
fields are the same and it appears so. atlas, i have no idea why my
insert into query does not work. if anyone has suggestions, it would
be appreciated. thanks in advance.

Set db = DBEngine(0)(0)
Set rst = db.OpenRecordset("ETracking")

If rst.RecordCount > 0 Then
Do While Not rst.EOF
db.Execute " INSERT INTO ETracking " _
& " ([ET Number], [ET LN Shortname], [ET Amount], [ET EC
Code])" _
& " SELECT(Max([ET Number])+1) AS [ET Number] FROM
ETracking), tblImportET.[ET LN Shortname], tblImportET.[ET Amount],
tblImportET.[ET EC Code] " _
& "FROM [tblImportET];"
rst.MoveNext

Loop

End If

Nov 12 '05 #3
The key thing is you had 2 from clauses and only one select.

On 3 Jan 2004 16:53:11 -0800, pi******@yahoo.fr (JMCN) wrote:
Steve Jorgensen <no****@nospam.nospam> wrote in message news:<4f********************************@4ax.com>. ..
The syntax of your SELECT is not correct. It looks as if you intend for the
first select column to be a subquery result, but you don't have a SELECT
statement inside the parentheses before the MAX function call.


i thought the select was my statement that added the new [et number].
thanks for the suggestion !!

jung
On 2 Jan 2004 12:21:59 -0800, pi******@yahoo.fr (JMCN) wrote:
>i received a runtime error message 3346 when i ran the insert into
>select code. i have check to see if the query values and destination
>fields are the same and it appears so. atlas, i have no idea why my
>insert into query does not work. if anyone has suggestions, it would
>be appreciated. thanks in advance.
>
>Set db = DBEngine(0)(0)
>Set rst = db.OpenRecordset("ETracking")
>
>If rst.RecordCount > 0 Then
> Do While Not rst.EOF
> db.Execute " INSERT INTO ETracking " _
> & " ([ET Number], [ET LN Shortname], [ET Amount], [ET EC
>Code])" _
> & " SELECT(Max([ET Number])+1) AS [ET Number] FROM
>ETracking), tblImportET.[ET LN Shortname], tblImportET.[ET Amount],
>tblImportET.[ET EC Code] " _
> & "FROM [tblImportET];"
> rst.MoveNext
>
> Loop
>
>End If


Nov 12 '05 #4
Steve Jorgensen <no****@nospam.nospam> wrote in message news:<vq********************************@4ax.com>. ..
The key thing is you had 2 from clauses and only one select.

thanks steve! i have finally added another select statement within my
insert into.

now what i am running to problems with is the recordset.
i have exactly 104 records. when i tested the code, the end result
was multiple records
for the same loan. where did i go wrong?
so i tried a couple of different do... loop statements and ended up
getting
the same results, that is having multiple records of the same loan.
so if anyone has any suggestions, it would be appreciated :)
thanks in advance and all who gave me advice. jung

Set db = DBEngine(0)(0)
Set rst = db.OpenRecordset("ETracking")

''If rst.RecordCount > 0 Then
''Do While Not rst.EOF
Do Until rst.EOF
db.Execute " INSERT INTO ETracking([ET Number], [ET LN
Shortname], [ET Amount], [ET EC Code])" _
& " SELECT(SELECT(Max([ET Number])+1) FROM ETracking),
tblImportET.[ET LN Shortname], tblImportET.[ET Amount],
tblImportET.[ET EC Code] FROM [tblImportET]; "
rst.MoveNext
Loop

Set rst = Nothing
Set tdf = Nothing
Set db = Nothing
'End If
Nov 12 '05 #5

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

Similar topics

14
by: serge | last post by:
I have a scenario where two tables are in a One-to-Many relationship and I need to move the data from the Many table to the One table so that it becomes a One-to-One relationship. I need to...
0
by: jtocci | last post by:
I'm having a big problem with CREATE RULE...ON INSERT...INSERT INTO...SELECT...FROM...WHERE when I want to INSERT several (20~50) records based on a single INSERT to a view. Either I get a 'too...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
0
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...
4
by: Chris Kratz | last post by:
Hello all, We have run into what appears to be a problem with rules and subselects in postgres 7.4.1. We have boiled it down to the following test case. If anyone has any thoughts as to why...
20
by: Mark Harrison | last post by:
So I have some data that I want to put into a table. If the row already exists (as defined by the primary key), I would like to update the row. Otherwise, I would like to insert the row. I've...
0
by: magnolia | last post by:
i created a trigger that will record the changes made to a table .everything works fine except the insert query.whenerever i try to insert a record it fires insert and update triger at the same time...
0
by: gpspocket | last post by:
help me -CURSOR backward insert from End Date > to Start Date how to insert dates from end to start like this SELECT 111111,1,CONVERT(DATETIME, '17/03/2008', 103), CONVERT(DATETIME,...
6
by: lenygold via DBMonster.com | last post by:
Hi everybody: What is the best way to I have 10 tables with similar INSERT requiremnts. INSERT INTO ACSB.VAATAFAE WITH AA(AA_TIN, AA_FILE_SOURCE_CD, .AA_TIN_TYP) AS ( SELECT AA_TIN,...
1
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...
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: 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
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...
0
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...
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
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.