I have an SQLServer database on a remote server which is used by our web site.
I have a set of reports which I built using MSAccess 2010 and I use ODBC to link to that SQLServer database.
I want to build a "Package Solution" to distribute the MSAccess database, but I don't want to give the database password to everyone who will install the solution.
I've assumed that I should have my MSAccess startup page have no recordsource, but in the "on open" event I should programmatically re-link the tables providing the password in code (which I'll secure). After successfully relinking the tables, I'll then open the 'real' main menu and close this 'initiator' form.
I'm having a problem relinking the tables. The tdf.RefreshLink always throws error 3151 ; "ODBC--connection to 'Cert123.dsn' failed."
Here is my code;
Dim dbs As Database
Dim tdf As TableDef
Dim Tdfs As TableDefs
Dim strConnect As String
Set dbs = CurrentDb
Set Tdfs = dbs.TableDefs
For Each tdf In Tdfs
If tdf.SourceTableName <> "" Then
strConnect = "ODBC;" & _
"Server=123.123.123.123,25000;" & _
"Database=DB123_Cert;" & _ "Uid=User123;" & _
"Password=mypwd123;" & _
"DSN=Cert123.dsn;" & _
"ProviderName=System.Data.SqlClient"
tdf.Connect = strConnect
tdf.RefreshLink
End If
Next
Any assist is appreciated (including if there is a better way to hide the database password in the published solution).
Dave