DoCmd RunSQL issue

G

Gary

I created a SQL that will work sometimes and other times it doesn't. When
it doesn't work, I copy and paste the SQL string from the immediate window
into a query in sql view. It normally doesn't work unless I remove some the
carrage returns and then I can select the normal query view and run the
query. The query will run then.

I don't know what is ADP, but I am using Access 2000 and vba code. The
command I use is:

DoCmd RunSQL SQLS

where SQLS is a String. I check the length of the String and its about
3030 characters in length.

Can someone please help.


Thank You,

Gary
 
T

Tony Toews [MVP]

Gary said:
DoCmd RunSQL SQLS

For starters use currentdb.execute SQLS, dbfailonerror.

That should give you error messages to help you figure out the
problem.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
D

David W. Fenton

For starters use currentdb.execute SQLS, dbfailonerror.

That should give you error messages to help you figure out the
problem.

If you use dbFailOnError, you really do need an error handler, or
the user is going to get a generic error message with the
Debug/Cancel/End choices, and that's not a good thing.
 
T

Tony Toews [MVP]

David W. Fenton said:
If you use dbFailOnError, you really do need an error handler, or
the user is going to get a generic error message with the
Debug/Cancel/End choices, and that's not a good thing.

Presumably if the poster is working in VBA they know about adding
error handling in each routine. I saw no need to explicitly mention
such.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
D

David W. Fenton

Presumably if the poster is working in VBA they know about adding
error handling in each routine. I saw no need to explicitly
mention such.

Well, I was writing Execute statements with dbFailOnError on the
recommendation of folks in the newsgroups for years before I
realized I needed an error handler. Obviously, I didn't encounter
any actual errors between the time I started using it and the point
at which I discovered I needed it.

In other words, don't assume that your readers know, because even
people like me, who have much more experience than your
garden-variety newbie can miss the obvious.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top