I have converted a project from DAO 3.6 Controls to ADO 2.8 by replacing the old DAO Data controls with ADO Data controls.
The DAO version connected to a password protected Access 97 database and the ADO version connects to a password protected Access 200 database. both databases have 4 tables which are related to to 4 controls on the form. Text box controls on the form are linked to the control fields
The ADO version runs OK but I am missing the ability to set the table source outside of the control.
using ADO i set the DatabaseName in the control to blank and then used the following code in the Form_Load
Dim MdbFile as Database
Dim IniFile as String
IniFile = App.Path + "\project.ini"
Call READINI ' ------reads database path and name from the INI file nto string PathToMdb
password = "aaaa" '----- password to access mdb file
Set MdbFile = DBEngine.Workspaces(0).OpenDatabase(PathToMdb, 0, 0, ";pwd=" & password)
dataexchange.DatabaseName = PathToMdb: dataexchange.Refresh
dataoverflt.DatabaseName = PathToMdb: dataoverflt.Refresh
DataTermnav.DatabaseName = PathToMdb: DataTermnav.Refresh
DataFIR.DatabaseName = PathToMdb: DataFIR.Refresh
in The ADO version I have used the ConnectionString property as:
Provider=Microsoft.JET.OLEDB.4.0;Data Source=c:\MyDirectory\MyTables.mdb;Jet OLEDB:Database Password=aaaa
If I relace this connectionstring with
Provider=Microsoft.JET.OLEDB.4.0;Data Source=PathToMdb;Jet OLEDB:Database Password=aaaa
I get an error
As the program is used in different environments where the name of the Access file and its location can vary, it is useful to use an external INI file to set the path so that it is not embedded in code.
Any Expert got the solution for me