I have created a SQL string the properly inserts a record in the table.
However, the insert does not occur at the end of the table. Instead
it inserts a record after the last record that I viewed. This would be
OK, except it assigns a autonumber to be one greater than the last
viewed record. This causes a duplicate autonumber. I know I can
change the autonumber index (Primary Key) to not allow duplicates.
How can I force the insert to use the highest autonumber + 1? I would
think that this should be handled automatically. 8 15940 pe********@comcast.net wrote: I have created a SQL string the properly inserts a record in the table. However, the insert does not occur at the end of the table. Instead it inserts a record after the last record that I viewed. This would be OK, except it assigns a autonumber to be one greater than the last viewed record. This causes a duplicate autonumber. I know I can change the autonumber index (Primary Key) to not allow duplicates.
How can I force the insert to use the highest autonumber + 1? I would think that this should be handled automatically.
Without seeing your code/script or knowing the sequence of events it's hard
to know what the issue is.
You talk about autonumber... is it actually an autonumber field or are you
manually creating your own? There is no way an real autonumber type field
will create a duplicate.
Either make is a real autonumner field, or insert Max([MyField]) + 1 as the
new value.
--
regards,
Br@dley
This is the true autonumber field created by access. I have not changed
it.
Does the "Insert Into" Command append the record at the bottom of the
file, or does it insert anywhere in the file?
This is the true autonumber field created by access. I have not changed
it.
Does the "Insert Into" Command append the record at the bottom of the
file, or does it insert anywhere in the file? pe********@comcast.net wrote: This is the true autonumber field created by access. I have not changed it.
Does the "Insert Into" Command append the record at the bottom of the file, or does it insert anywhere in the file?
Tried the help file?
"If you append records to a table with an AutoNumber field and you want to
renumber the appended records, do not include the AutoNumber field in your
query. Do include the AutoNumber field in the query if you want to retain
the original values from the field."
--
regards,
Br@dley
I started with the help file. I understand the help data. However,
the issue still exists.
the sql is "Insert into table ( name, address, city ) values ( "XXX",
"YYY", "ZZZ" ).
This command does not use the AUTONUMBER field, called (RcdNumber). It
does not append with a new higher autonumber value. It does replicate
and existing number.
There's something wrong with your db try compact and repair and see if that
fixes it.
--
Terry Kreft
<pe********@comcast.net> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com... I started with the help file. I understand the help data. However, the issue still exists. the sql is "Insert into table ( name, address, city ) values ( "XXX", "YYY", "ZZZ" ).
This command does not use the AUTONUMBER field, called (RcdNumber). It does not append with a new higher autonumber value. It does replicate and existing number.
On Fri, 3 Mar 2006 12:40:34 +1100, "Br@dley" <cu@dendof.it> wrote:
And put that primary key back! Your "business rule" obviously is that
you don't want duplicates. So let the db engine enforce that rule. If
you ever get a "unique index violation" error, 99.9999% chance it's
your programming error, and an opportunity to improve your code.
-Tom. pe********@comcast.net wrote: I have created a SQL string the properly inserts a record in the table. However, the insert does not occur at the end of the table. Instead it inserts a record after the last record that I viewed. This would be OK, except it assigns a autonumber to be one greater than the last viewed record. This causes a duplicate autonumber. I know I can change the autonumber index (Primary Key) to not allow duplicates.
How can I force the insert to use the highest autonumber + 1? I would think that this should be handled automatically.
Without seeing your code/script or knowing the sequence of events it's hard to know what the issue is.
You talk about autonumber... is it actually an autonumber field or are you manually creating your own? There is no way an real autonumber type field will create a duplicate.
Either make is a real autonumner field, or insert Max([MyField]) + 1 as the new value.
Thanks for all the input. The key as marked as no duplicate. However,
I deleted the key and the field. COmpressed and reapired, rebuilt the
field and index, did another compress and rebuilt. It all works
correctly . It was apparently a database corruption error. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Carl |
last post by:
Hi,
I hope someone can share some of their professional advice and help me out
with my embarissing problem concerning an Access INSERT query. I have never
attempted to create a table with...
|
by: Ivan Sammut |
last post by:
Hi,
I have a table which the first field is an autonumber field as is also my
keyfield. Now I want to know if it is possible that after I do an insert
stament I can get what the value of this...
|
by: Jan |
last post by:
I have a table with autoincrement unique ID plus name (required not to
be blank) and other fields.
I have a list of names in another table and would like to do insert to
the name field of the...
|
by: Cindy H |
last post by:
Hi
I'm having a problem getting the insert statement correct for an Access
table I'm using.
The Access table uses an autonumber for the primary key.
I have tried this:
INSERT INTO Tournaments...
|
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...
|
by: rn5a |
last post by:
In a ASP applicatiuon, the FOrm has a textbox & a select list where
the admin can select multiple options. Basically the admin has to
enter the name of a new coach in the textbox & select the...
|
by: Lyn |
last post by:
Hi,
Is there an "easy" way to write a full record (all fields) using "INSERT
INTO..." into a table which has an AutoNumber field?
Normally, to write a full new record I would use:
INSERT INTO...
|
by: ramzansadiq |
last post by:
Hi guru's,
I m unable to find how to Insert a primary key which is also an autonumber field into Table. My query is as below.It is inserting record if i m hardcoding the ID Field. It is VBA Access...
|
by: Ken Foskey |
last post by:
I need to trap an insert on an MS access table that uses a generated
typed table and row setup. I have to trap the insert and then hook up
and get the autonumber value for the insert. I have...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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: 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...
|
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...
|
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...
| | |