New Error Message Cannot Open Database (1 Viewer)

iankerry

Registered User.
Local time
Today, 17:34
Joined
Aug 10, 2005
Messages
190
Hi All,

I have been using this button for years and it has always worked. The button puts info from the database into an email).
But suddenly I get the error -2147467259 ODBC "Cannot open database (unknown). It may not be a database that your application recognizes or the file may be corrupt".

I have tried backups going back many months and get the same message. So I don't think it is corrupt.

I am on Win 7 - Access 2013. Connect to an SQL server. Here is the code that it stops on the cn.open command:

Code:
Public Function OpenConnection() As Boolean
    On Error GoTo OpenConnection_Err

    Set cn = New ADODB.Connection
       If cn.State <> adStateClosed Then cn.Close
          cn = "Driver={Microsoft Access Driver (*.mdb, *.accdb)};" & _
          "Dbq=flicks database.accdb;" & _
          "DefaultDir=z:\databases\;" & _
          "Uid=Admin;Pwd=;"
    
    MsgBox cn
  [COLOR="Red"]  cn.Open[/COLOR]
    cn.CommandTimeout = 0

    Set rs = New ADODB.Recordset
    If cn.State <> adStateClosed Then OpenConnection = True


I have double, nay triple, checked the name and path.

As I say nothing that I know of has changed - unless MS has done an update. So I can't work out why it has suddenly stopped working.

Anyone any ideas please?!

Thanks
Ian
 

Mile-O

Back once again...
Local time
Today, 17:34
Joined
Dec 10, 2002
Messages
11,316
Shot in the dark: ADO reference isn't missing, is it?
 

iankerry

Registered User.
Local time
Today, 17:34
Joined
Aug 10, 2005
Messages
190
Thanks for the reply. They seems to be ok, Access, Office and Outlook 15 and ADO 2.8.

Ian
 

iankerry

Registered User.
Local time
Today, 17:34
Joined
Aug 10, 2005
Messages
190
Is this a clue?

I just put a 'watch' on the value of cn.

Under default database it says "Operation is not allowed when the object is closed"

Now, if this is talking about the database, then it clearly isn't closed, because I am in it when I run the code!

So does it mean something else?

Ian
 

iankerry

Registered User.
Local time
Today, 17:34
Joined
Aug 10, 2005
Messages
190
Hi All

Has no-one any ideas for me? My button is still not working!

Thanks

Ian
 

Users who are viewing this thread

Top Bottom