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

INSERT INTO not dependable

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 is that
Access is trying to assign invalid numbers into the AutoNumber field
when it creates new records, and therefore it just quietly rejects the
record. If I try several times, it finally takes. Could I be right
about that? If so, how do I fix it?

John King
Boise, Idaho

Nov 25 '06 #1
8 1783
On 25 Nov 2006 09:38:16 -0800, jk******@cableone.net wrote:

You're probably wrong about the Autonumbers. If you insert 1 record
per second, 24/7, it has enough numbers for 140 years.

You don't mention any error message. That's probably because you've
turned them off using:
DoCmd SetWarnings False
Make sure you have warnings on, so Access will tell you WHY it
couldn't insert the record.
An alternative is:
CurrentDb.Execute sqlstatement, dbFailOnError
You'll likely find a violation of referential integrity, a unique
index, or a required field.

-Tom.

>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 is that
Access is trying to assign invalid numbers into the AutoNumber field
when it creates new records, and therefore it just quietly rejects the
record. If I try several times, it finally takes. Could I be right
about that? If so, how do I fix it?

John King
Boise, Idaho
Nov 25 '06 #2
Is it possible that the record is being inserted, but not where you think it
should be?
I have read that Access witll reuse old deleted autonumber generated keys.
have you checked the record count before and after?

<jk******@cableone.netwrote in message
news:11**********************@h54g2000cwb.googlegr oups.com...
>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 is that
Access is trying to assign invalid numbers into the AutoNumber field
when it creates new records, and therefore it just quietly rejects the
record. If I try several times, it finally takes. Could I be right
about that? If so, how do I fix it?

John King
Boise, Idaho


Nov 25 '06 #3
Tom van Stiphout wrote:
You don't mention any error message. That's probably because you've
turned them off using:
DoCmd SetWarnings False
Make sure you have warnings on, so Access will tell you WHY it
couldn't insert the record.
An alternative is:
CurrentDb.Execute sqlstatement, dbFailOnError
Yup. I see so many people advising newbies to use DoCmd SetWarnings
False and in my opinion, it's the worst possible advice.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 26 '06 #4
I have to concur with both Tom and Tim, do not set the warmings to
false for general running of code, but I will say that it is
understandable that while running an insert query via code you may want
to do this so that the users do not see and unfriendly 'Access is about
to insert 123 rows of data' message, it also gives them the option to
cancel, which may undesirable, however after you have run your query
make sure you turn them back on straight away and be aware of what you
have done. You mention that many records have been deleted, it could
be that inserting the records would create orphaned records, or break
the rules that have been created for that table. If you turn the
warning back on, all be it temporarily, access will tell you why it is
not inserting certain row, and then will allow you to carry on with
inserting the records that you can or cancel the whole insert. I would
recommend that you cancel the whole insert until you have found out why
certain records did not make it.

Good luck

Nick

Tim Marshall wrote:
Tom van Stiphout wrote:
You don't mention any error message. That's probably because you've
turned them off using:
DoCmd SetWarnings False
Make sure you have warnings on, so Access will tell you WHY it
couldn't insert the record.
An alternative is:
CurrentDb.Execute sqlstatement, dbFailOnError

Yup. I see so many people advising newbies to use DoCmd SetWarnings
False and in my opinion, it's the worst possible advice.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 26 '06 #5
On Sun, 26 Nov 2006 00:16:34 -0330, Tim Marshall
<TI****@PurplePandaChasers.Moertheriumwrote:
>Tom van Stiphout wrote:
>You don't mention any error message. That's probably because you've
turned them off using:
DoCmd SetWarnings False
Make sure you have warnings on, so Access will tell you WHY it
couldn't insert the record.
An alternative is:
CurrentDb.Execute sqlstatement, dbFailOnError

Yup. I see so many people advising newbies to use DoCmd SetWarnings
False and in my opinion, it's the worst possible advice.
You must mean without SetWarnings True afterward. You may not
want... "Are you sure you want to delete one record" etc.

Nov 26 '06 #6
Tom Becker wrote:
>>Yup. I see so many people advising newbies to use DoCmd SetWarnings
False and in my opinion, it's the worst possible advice.

You must mean without SetWarnings True afterward. You may not
want... "Are you sure you want to delete one record" etc.
Nope even with that. It's a careless practice. As is happening with
the OP, you don't get any warning that errors are occuring. And you can
be sure that no matter how certain you are of your code, that you will
eventually have errors.

In fact, in a properly structured database with primary key constraints,
you WANT to throw and trap error 3022 to let the user know they are
trying to store a duplicate primary key.

The DAO execute method:

db.execute strSql, dbFailOnError

Where db is a DAO database object such as currentdb, is a far, far
better way of doing it and superior in every way possible to the
setWarnings bandaid.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 27 '06 #7
Nick 'The Database Guy' wrote:
I have to concur with both Tom and Tim, do not set the warmings to
false for general running of code, but I will say that it is
understandable that while running an insert query via code you may want
to do this so that the users do not see and unfriendly 'Access is about
to insert 123 rows of data' message,
The DAO execute method:

db.execute strSql, dbFailOnError

Where db is a DAO database object such as currentdb, does not produce
such messages.

USing setwarnings is, bluntly, careless programming. In my opinion, of
course.

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 27 '06 #8
Hi Tim,

I would agree with you that DoCmd.SetWarnings is certainly not the most
professional approach that one could adopt.

It is been many years since I used this statement myself however I was
just answering a question, not embarking on a voyage of VBA discovery.

Good luck

Nick

Tim Marshall wrote:
Nick 'The Database Guy' wrote:
I have to concur with both Tom and Tim, do not set the warmings to
false for general running of code, but I will say that it is
understandable that while running an insert query via code you may want
to do this so that the users do not see and unfriendly 'Access is about
to insert 123 rows of data' message,

The DAO execute method:

db.execute strSql, dbFailOnError

Where db is a DAO database object such as currentdb, does not produce
such messages.

USing setwarnings is, bluntly, careless programming. In my opinion, of
course.

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Dec 2 '06 #9

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

Similar topics

3
by: Howard Hinnant | last post by:
I recently asked for a survey of multimap insert with hint behavior, in support of a paper I'm writing concerning lwg issue 233. My sincere thanks to Beman Dawes, Raoul Gough, Russell Hind, Bronek...
6
by: Mark P | last post by:
Some time ago I posted here about inserting into a set with a hint: ...
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...
2
by: Ford Desperado | last post by:
I've been reading the docs and playing around, but I'm still not getting the difference. For instance, create table a(i int check(i>0)) create table a_src(i int) go create unique index ai on...
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...
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...
2
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request :...
3
by: MP | last post by:
Hi Posted this several hours ago to another ng but it never showed up thought i'd try here. using vb6, ado, .mdb, jet4.0, no access given table tblJob with field JobNumber text(10) 'The...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.