This is driving me bonkers! I have an Access Data Project, which on start-up opens a form. What happens is if the SQL Server/database is offline, doesn't exist, whatever, I get the following dialog:
"Access is unable to connect to [db name] database on the [SQL server name] server. Make sure that the database still exists and that the server is running."
This error occurrs before my start-up form fires (and it actually still opens after hitting OK on the error dialog.)
There doesn't seem to be an event, property, etc., at the ADP level where you can have code run to check if the ADP is actually connected to SQL Server successfully.
I thought about adding the following code somewhere:
Public Function IsADPConnected() As Boolean
If CurrentProject.IsConnected Then
IsADPConnected = True
MsgBox "The system is unavailable at this time." & vbCrLf _
& "Please contact the help desk for further assistance.", vbCritical
IsADPConnected = False
...however, I can't find a place anywhere to make a call to my IsADPConnected function. I was going to do something like:
If Not IsADPConnected Then
Does anyone have any ideas on how to trap for this error or maybe use some creative way to accomplish the same thing?
I have just started converting my MDBs to ADPs with a SQL Server backend. Right now I only have two test environments (Laptop and Server) but I am very interested in a solution.
I have only done a cursory search for details, but I found OpenConnection and the BaseConnectionString property. This looks like the way to change the connection for the ADP, but as far as trapping the error I am still looking. I just wanted to respond to your post to let you know I am interested and will continue to look for a solution. So if you don't mind sharing anything you find, I will do the same.
I plan to do some more looking tomorrow and will update you with anything I find.