Hello All!
I’m working on an Access 2000 database and in the global module a connection to the actual database itself is set up (I’ve pasted the code below):
Function GetDBConnection()
‘Open the Connection Object
Set Conn = New ADODB.Connection
Conn.Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:DatabasesProductReleaseControl.mdb;”
GetDBConnection = Conn
End Function
This function is called several places through out the database in the forms and reports. Below is an example:
Dim GetArgentinaRS As ADODB.Recordset
Dim strArgentinaSQL
‘Open the ADO Recordset object
Set GetArgentinaRS = New ADODB.Recordset
GetArgentinaRS.ActiveConnection = Conn
strArgentinaSQL = “SELECT * FROM RRAImportation WHERE Country = 1”
GetArgentinaRS.Open strArgentinaSQL
The problem is I need to be able to put this entire database where I want. Since the data source is set in the global file, unless you put the database where the global file is set, or you change the global file to reflect the new location of the database, the database fails as soon as it hits code the calls the GetDBConnection() function. So, here is my question – Can I set the data source to be dynamic so that where ever the database is placed it will run correctly? If I can’t then is there another way I can run SQL statements in code like the one above without using the conn object for my connection?
Thanks for your help,
Amanda Segelstrom