Appending to the ConnectionString - How?

K

Koorosh

Hi everyone

I am trying to append a string to my access project's connection string.

CurrentProject.Connection.ConnectionString=
CurrentProject.Connection.ConnectionString & "Jet OLEDB:System
database=C:\workgroupInfo.mdw;"

I keep getting an error message saying: can't do this while the object is
open. I then add code to close the project's connection before appending to
its connectionstring. I still get an error message saying that the close
operation failed.

What gives?

Where in the project, and how do I append to the CurrentProject.Connection's
connectionstring?


Thanks
 
S

Scott McDaniel

Hi everyone

I am trying to append a string to my access project's connection string.

CurrentProject.Connection.ConnectionString=
CurrentProject.Connection.ConnectionString & "Jet OLEDB:System
database=C:\workgroupInfo.mdw;"

I keep getting an error message saying: can't do this while the object is
open. I then add code to close the project's connection before appending to
its connectionstring. I still get an error message saying that the close
operation failed.

What gives?

The ConnectionString property of the Connection object is read-only. What exactly are you trying to do? The
CurrentProject.Connection refers to the current ADO connection (below from online help):

You can use the Connection property to return a reference to the current ActiveX Data Objects (ADO) Connection object
and its related properties. Read-only Connection

If you're trying to set a workgroup, you'd do this when Access opens, typically in a shortcut you use to open the
database. To do that, build a new shortcut and set the Target like this:

"full path to msaccess.exe" "full path to your database" /wrkgrp "full path to workgroup file"

Links:

Connection object: http://msdn2.microsoft.com/en-us/library/aa224114(office.11).aspx
ConnectionString property: http://msdn2.microsoft.com/en-us/library/aa224110(office.11).aspx

Be careful of the above links, you mayl need to copy/paste them into your browser to get it to work
Where in the project, and how do I append to the CurrentProject.Connection's
connectionstring?


Thanks

Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top