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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to trap a SQL7 error from within Excel?

Status
Not open for further replies.

j9

Programmer
Joined
Jun 6, 2001
Messages
90
Location
US
My Excel worksheet contains several dataranges that each use a trusted connection. It works great when the NT user is allowed access to the database. BUT, if an NT user is not allowed access to the database: as soon as querytable(1).refresh executes, a Microsoft SQL Server Login error box pops up saying 'Connection failed:, etc...'.
I tried to handle this error with VB 'On Error' code, but apparently it's not recognized as an error because it never gets trapped. I guess it's a provider error and not an Excel error. So, is there a way to trap this type of error so that I can control what happens if a user is or isn't allowed access to the database? If so, how?
 
IF you need Error Traping the Best way is to Generate an Excell File from the SQL Data using VB and DTS, that will allow you to authenthicate and trap and log errors.
Excell wants what the data ready does not what to deal with problems geting the data AL Almeida
NT/DB Admin
"May all those that come behind us, find us faithfull"
 
Generating an Excel file is not an option.
 
Nevermind. I have a work-around. In the auto_open() event, I use normal VB error handling code and ADO code to attempt a Trusted Connection to the SQL Server. If the connection fails, it goes to my error handler. I still have no idea why the error handling code ignores failed connections associated with data range refreshes, but at least I have something that'll do the trick!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top