By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,010 Members | 2,774 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,010 IT Pros & Developers. It's quick & easy.

Cannot find answer to what seems simple error problem for insertinginto table

P: n/a
I posted a question before (to too many groups) and this time I am
sending to this group only. I have a quick script as seen below, the
file_list table has a unique field called file_name.

The problem I am having is that if no unique items exist, this will
insert into the table fine. But if a unique item does exist it will not
insert as it should. My problem is that I can not get access to return
any kind of error. This is very frustrating as I have scowered the net
for what is a seemingly easy thing to do.

What am I doing wrong here? Is there a better way to do this? My real
program is a fairly big sql insert script repeated many times and it is
failing for one reason or another. But I cannot find out why because I
cannot print the errors that are returned.
db = CurrentDb()
CurrentDb.Execute "insert into file_list (file_name) VALUES (test.txt)"
MsgBox ("good")
Debug.Print Err.Description
Debug.Print Err.Number

Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
frank wrote:
I posted a question before (to too many groups) and this time I am
sending to this group only. I have a quick script as seen below, the
file_list table has a unique field called file_name.

The problem I am having is that if no unique items exist, this will
insert into the table fine. But if a unique item does exist it will not
insert as it should. My problem is that I can not get access to return
any kind of error. This is very frustrating as I have scowered the net
for what is a seemingly easy thing to do.

What am I doing wrong here? Is there a better way to do this? My real
program is a fairly big sql insert script repeated many times and it is
failing for one reason or another. But I cannot find out why because I
cannot print the errors that are returned.
db = CurrentDb()
CurrentDb.Execute "insert into file_list (file_name) VALUES (test.txt)"
MsgBox ("good")
Debug.Print Err.Description
Debug.Print Err.Number


Add quotes around Test.Txt
CurrentDb.Execute "insert into file_list (file_name) VALUES ('test.txt')"

Nov 12 '05 #2

P: n/a
Problem is though, I cannot get access to print the error. I want to see
the errors I cannot get access to report them? Why?

Salad wrote:
frank wrote:
I posted a question before (to too many groups) and this time I am
sending to this group only. I have a quick script as seen below, the
file_list table has a unique field called file_name.

The problem I am having is that if no unique items exist, this will
insert into the table fine. But if a unique item does exist it will
not insert as it should. My problem is that I can not get access to
return any kind of error. This is very frustrating as I have scowered
the net for what is a seemingly easy thing to do.

What am I doing wrong here? Is there a better way to do this? My real
program is a fairly big sql insert script repeated many times and it
is failing for one reason or another. But I cannot find out why
because I cannot print the errors that are returned.
db = CurrentDb()
CurrentDb.Execute "insert into file_list (file_name) VALUES
(test.txt)"
MsgBox ("good")
Debug.Print Err.Description
Debug.Print Err.Number


Add quotes around Test.Txt
CurrentDb.Execute "insert into file_list (file_name) VALUES ('test.txt')"


Nov 12 '05 #3

P: n/a
Problem is half solved. I had to set zero length fields and that was
causing the error. But why do errors not get generated anyway? It would
be nice is the sql engine said "Field <a> has a problem"..

Would still like to find out how to print sql errors frp, currentdb.execute.

frank wrote:
I posted a question before (to too many groups) and this time I am
sending to this group only. I have a quick script as seen below, the
file_list table has a unique field called file_name.

The problem I am having is that if no unique items exist, this will
insert into the table fine. But if a unique item does exist it will not
insert as it should. My problem is that I can not get access to return
any kind of error. This is very frustrating as I have scowered the net
for what is a seemingly easy thing to do.

What am I doing wrong here? Is there a better way to do this? My real
program is a fairly big sql insert script repeated many times and it is
failing for one reason or another. But I cannot find out why because I
cannot print the errors that are returned.
db = CurrentDb()
CurrentDb.Execute "insert into file_list (file_name) VALUES (test.txt)"
MsgBox ("good")
Debug.Print Err.Description
Debug.Print Err.Number


Nov 12 '05 #4

P: n/a
Frank,

If you try

db.execute 'string', dbfailonerror

you should have the query feed some sort of error into your routine,
however, the Access query engine is not designed to teach you how to use
Access or to teach you SQL, that is something you must learn yourself and
from what I have seen, I would recommend you do a course (for your data and
sanity's sake!).

A VBA course would prolly be the best as things like VBA query options are
taught in it (I think...)

Best Regards
Antoin the...

"frank" <zi***@zip.com> wrote in message
news:HB*******************@bignews4.bellsouth.net. ..
Problem is half solved. I had to set zero length fields and that was
causing the error. But why do errors not get generated anyway? It would
be nice is the sql engine said "Field <a> has a problem"..

Would still like to find out how to print sql errors frp, currentdb.execute.
frank wrote:
I posted a question before (to too many groups) and this time I am
sending to this group only. I have a quick script as seen below, the
file_list table has a unique field called file_name.

The problem I am having is that if no unique items exist, this will
insert into the table fine. But if a unique item does exist it will not
insert as it should. My problem is that I can not get access to return
any kind of error. This is very frustrating as I have scowered the net
for what is a seemingly easy thing to do.

What am I doing wrong here? Is there a better way to do this? My real
program is a fairly big sql insert script repeated many times and it is
failing for one reason or another. But I cannot find out why because I
cannot print the errors that are returned.
db = CurrentDb()
CurrentDb.Execute "insert into file_list (file_name) VALUES (test.txt)" MsgBox ("good")
Debug.Print Err.Description
Debug.Print Err.Number

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.