Capture which query is being run

P

PiB311

Hi all,

Thanks for any help in advance.

I have a procedure that runs a daily update for an application. This
procedure has a number of queries that from time to time cause an error. I
am familiar with error handling and am using the err.description to get the
reason for the error, but I need to find a way to capture which query caused
the error.

I thought about doing this:

On Error GoTo HandleError

'Delete all records from tblProjectInfoTemp.
str_error = "qryPITempDelete"
DoCmd.OpenQuery "qryPITempDelete"

'Append records from Project Office to tblProjectInfoTemp.
str_error = "qryPITempAppend"
DoCmd.OpenQuery "qryPITempAppend"

HandleError:

str_sql = "INSERT INTO tbl_process_log ( process_id , status_id ,
error_message , error_action ) " & _
"SELECT " & rst!process_id & ", 3, '" &
Err.Description & "','" & str_error & "' "

DoCmd.RunSQL str_sql
DoCmd.SetWarnings True


I know the syntax for the insert on this type of SQL statement should
include the Values syntax instead of Select, but will change that later.

Please let me know if there is an easier way to accomplish this. There is
one process that runs up to 180 queries and to do this for each one would be
painstakingly slow.
 
J

John Spencer MVP

Unfortunately I cannot think of any alternative

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
P

PiB311

Thanks for the help! Anyone else having difficulty posting replies i this
forum? I can post questions but get errors on the response.
 
J

JimBurke via AccessMonster.com

How are you getting to the forum? There are multiple ways - Microsofts Forum
link, Access Monster and others. I quit using the Microsoft link because of
all the errors I was getting thru it. I haven't had any problems accessing it
thru Access Monster. If you are already using Access Monster then I have no
idea why you'd be getting errors. Here's the Access Monster link if you're
not already using it:



This brings you to the June page - they have it set up so that you view by
months.I end up creating a new Explorer Favorites link at the beginning of
each month so I can go directly to the current month.

Thanks for the help! Anyone else having difficulty posting replies i this
forum? I can post questions but get errors on the response.
Unfortunately I cannot think of any alternative
[quoted text clipped - 41 lines]
 

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