473,473 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

access 97: INSERT and Append queries

is it possible to insert a value into a field when you append the new
records to the table instead of appending
the one new record at a time in order to insert a new value?

for example, i would like to insert the next "ET Number" when I append
new records into the tblImportET.

= [Etracking]![ET Number] + 1

i tried this sql code but i received an input pop-up box indicating i
need to enter the "[Etracking]![ET Number]
parameter value". the Etracking is the table that I want to append the
new records to it.

INSERT INTO ETracking ( [ET Number], [ET LN Shortname], [ET Amount],
[ET EC Code] )
SELECT tblImportET.[ET Number], tblImportET.[ET LN Shortname],
tblImportET.[ET Amount], tblImportET.[ET EC Code]
FROM tblImportET
WHERE (((tblImportET.[ET Number])=[Etracking]![ET Number]+1));

if anyone has suggestions, it would be appreciated .
thanks in advance - jung.
Nov 12 '05 #1
4 5845
What, in your statement, would be telling it to add one to the _last ET
number? In fact, the expression you used doesn't appear to select the ET
number for any _particular_ record.

Take a look in Help at the DMax function, if this is a number that must be
displayed to people and could, thus, cause some consternation if it were not
exactly sequential. If it is not to be viewed by people, but only internally
for joins and foreign keys, then consider using an AutoNumber field.

Larry Linson
Microsoft Access MVP

"JMCN" <pi******@yahoo.fr> wrote in message
news:27**************************@posting.google.c om...
is it possible to insert a value into a field when you append the new
records to the table instead of appending
the one new record at a time in order to insert a new value?

for example, i would like to insert the next "ET Number" when I append
new records into the tblImportET.

= [Etracking]![ET Number] + 1

i tried this sql code but i received an input pop-up box indicating i
need to enter the "[Etracking]![ET Number]
parameter value". the Etracking is the table that I want to append the
new records to it.

INSERT INTO ETracking ( [ET Number], [ET LN Shortname], [ET Amount],
[ET EC Code] )
SELECT tblImportET.[ET Number], tblImportET.[ET LN Shortname],
tblImportET.[ET Amount], tblImportET.[ET EC Code]
FROM tblImportET
WHERE (((tblImportET.[ET Number])=[Etracking]![ET Number]+1));

if anyone has suggestions, it would be appreciated .
thanks in advance - jung.

Nov 12 '05 #2
rkc

"JMCN" <pi******@yahoo.fr> wrote in message
news:27**************************@posting.google.c om...
is it possible to insert a value into a field when you append the new
records to the table instead of appending
the one new record at a time in order to insert a new value?

for example, i would like to insert the next "ET Number" when I append
new records into the tblImportET.

= [Etracking]![ET Number] + 1

i tried this sql code but i received an input pop-up box indicating i
need to enter the "[Etracking]![ET Number]
parameter value". the Etracking is the table that I want to append the
new records to it.

INSERT INTO ETracking ( [ET Number], [ET LN Shortname], [ET Amount],
[ET EC Code] )
SELECT tblImportET.[ET Number], tblImportET.[ET LN Shortname],
tblImportET.[ET Amount], tblImportET.[ET EC Code]
FROM tblImportET
WHERE (((tblImportET.[ET Number])=[Etracking]![ET Number]+1));


What you are hoping for would look more like the following, except for
the fact that it doesn't work. The query selects the highest ET Number
from ETracking, adds one to it and uses that same value for each
record appended.

INSERT INTO ETracking (
[ET Number],
[ET LN Shortname],
[ET Amount],
[ET EC Code]
)
SELECT
(SELECT MAX([ET Number])+1 AS ETracking FROM ETracking),
tblImportET.[ET LN Shortname],
tblImportET.[ET Amount],
tblImportET.[ET EC Code]
FROM tblImportET

Perhaps someone who actually knows SQL has a real solution.
Nov 12 '05 #3
"rkc" <rk*@yabba.dabba.do.rochester.rr.nope> wrote in message news:<iY*******************@twister.nyroc.rr.com>. ..
"JMCN" <pi******@yahoo.fr> wrote in message
news:27**************************@posting.google.c om...
is it possible to insert a value into a field when you append the new
records to the table instead of appending
the one new record at a time in order to insert a new value?

for example, i would like to insert the next "ET Number" when I append
new records into the tblImportET.

= [Etracking]![ET Number] + 1

i tried this sql code but i received an input pop-up box indicating i
need to enter the "[Etracking]![ET Number]
parameter value". the Etracking is the table that I want to append the
new records to it.

INSERT INTO ETracking ( [ET Number], [ET LN Shortname], [ET Amount],
[ET EC Code] )
SELECT tblImportET.[ET Number], tblImportET.[ET LN Shortname],
tblImportET.[ET Amount], tblImportET.[ET EC Code]
FROM tblImportET
WHERE (((tblImportET.[ET Number])=[Etracking]![ET Number]+1));


What you are hoping for would look more like the following, except for
the fact that it doesn't work. The query selects the highest ET Number
from ETracking, adds one to it and uses that same value for each
record appended.

INSERT INTO ETracking (
[ET Number],
[ET LN Shortname],
[ET Amount],
[ET EC Code]
)
SELECT
(SELECT MAX([ET Number])+1 AS ETracking FROM ETracking),
tblImportET.[ET LN Shortname],
tblImportET.[ET Amount],
tblImportET.[ET EC Code]
FROM tblImportET

Perhaps someone who actually knows SQL has a real solution.


Okay - thanks the suggestions!

I have tried to rewrite the DMax sql but I receive the compile error
message of "line number or lable or statemetn or end of statement".
It's probably very obvious but I'm have looked at it for so long that
I can't tell what's wrong with the syntax anymore. Any help would be
greatly appreciated again.
thanks in advance - jung.

If rs.RecordCount > 0 Then
Do While Not rst.EOF
strSQL = "INSERT INTO ETracking ([ET Number],[ET LN
Shortname],[ET Amount],[ET EC Code]);"
'error message received on the next line
"SELECT(DMax([ET Number])+1) AS [ET Number] FROM
ETracking, tblImportET.[ET LN Shortname], tblImportET.[ET Amount],
tblImportET.[ET EC Code] FROM tblImportET";
DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True
rst.MoveNext

Loop
end if
Nov 12 '05 #4
JMCN wrote:
is it possible to insert a value into a field when you append the new
records to the table instead of appending
the one new record at a time in order to insert a new value?

for example, i would like to insert the next "ET Number" when I append
new records into the tblImportET.

= [Etracking]![ET Number] + 1

i tried this sql code but i received an input pop-up box indicating i
need to enter the "[Etracking]![ET Number]
parameter value". the Etracking is the table that I want to append the
new records to it.

INSERT INTO ETracking ( [ET Number], [ET LN Shortname], [ET Amount],
[ET EC Code] )
SELECT tblImportET.[ET Number], tblImportET.[ET LN Shortname],
tblImportET.[ET Amount], tblImportET.[ET EC Code]
FROM tblImportET
WHERE (((tblImportET.[ET Number])=[Etracking]![ET Number]+1));

if anyone has suggestions, it would be appreciated .
thanks in advance - jung.

Try changing the last line of your SQL to read :

" .... WHERE (((tblImportET.[ET Number])=" & [Etracking]![ETNumber] & "
+1 )); "

Mike W :)

Nov 12 '05 #5

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

Similar topics

2
by: zlatko | last post by:
There is a form in an Access Project (.adp, Access front end with SQL Server) for entering data into a table for temporary storing. Then, by clicking a botton, several action stored procedures...
5
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...
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...
2
by: Noloader | last post by:
Hello, Access XP, SQL Server 2000 Is it possible to hide a SP under Queries in Access, yet still be able to Execute it from Access? (Similar to hiding Tables, then using Views) We hooked...
8
by: Bruce Dodds | last post by:
When run manually, my query appends 14 records. When run from code using CurrentProject.Connection.Execute, the same query appends 11 records. Does anyone have an explanation of why this could be...
4
by: Shahzad | last post by:
dear respected gurus, I would like to knew how to apply append,insert query for a self table where no primary keys issues. i do have problem say there are 5 rows of single record, this is data...
4
by: Andrew Chanter | last post by:
I have been working with an A97 database that performs a data processing function. It imports data from a flat text file then uses a dao transaction that executes a number of sql statements (about...
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...
4
MMcCarthy
by: MMcCarthy | last post by:
To view Access queries in SQL rather than Access query design - open the query design window and change the view to SQL: Select Statement SELECT FROM ; Append Statement INSERT INTO (, , )...
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...
1
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.