Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Error Message - How do I hide it, or not display it.

Status
Not open for further replies.

mystuff

Programmer
Apr 30, 2004
86
0
0
US
Hi,

I have created a form that allows a user to enter an excel file name. The code imports the file into a table. Then a query joins the table to another table and then exports the results out into another excel file.

When the join field (Project Number) is not in the original file, the query will not run. I have an "On Error goto clause in my code. It goes to a message box to tell the user what is wrong. I also have "DoCmd.SetWarnings False".

However, when this problem occurs, the Query Error is displayed first. Then, if the user selects "Cancel", the "On Error" clause kicks in and the user see's my message.

How can I turn this error message off. Or, better yet, how can I determine if the query will work before running it and therby giving the user the error message.

I hope all of this makes sense. Thanks in advance.
 
find out what the error number is and code accordingly in the errorhandler

if err.number = ?????? then

end if

to trun the error messages off in the errorhandler enter

err.clear

hope this helps.
 
Thanks,

But I have already done this. The problem is that the error comes up because the query is expecting a field that is not in the excel spreadsheet. So the error comes up before the "On Error" takes place. If I click "cancel", my error handler does kick in and I get my message. But I don't want to see the query error message.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top