Question : How do I change the currentproject.connection during run-time (or startup)?

I have a access project that normally connects to a SQL server, BUT there is a possibility (because the app will be commonly used on laptops) that the app will run independently from the SQL server so it will have limited functionality with a local DB connection.  How do I tell Access to change its connection properties on startup or at runtime using VBA?  I've tried:

        Application.CurrentProject.CloseConnection
        Application.CurrentProject.Connection = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & cLocalDataPath & "local.mdb"

AND

        CurrentProject.Connection.Cancel '<---- or connection.close or closeconnection
        CurrentProject.Connection.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & cLocalDataPath & "HBACFPST.mdb"

there's always an error when I try to change the connectionstring.  Help!

Answer : How do I change the currentproject.connection during run-time (or startup)?


One last thought before I go home. What does this do for you?

Application.CurrentProject.OpenConnection "Whatever", "userid", "password"
Random Solutions  
 
programming4us programming4us