I’m so close but I just can’t find exactly what I need. I’m trying to create a dsn-less connection to a Foxpro table (through the dbc). The following code works great only it requires the DSN to be setup. How would I modify this so that the DSN is not required on the user’s computer?
Public Sub DSNFP()
Dim db As DAO.Database
Dim td As DAO.TableDef
Dim ConnectString As String
Set db = CurrentDb
ConnectString = “ODBC;DSN=FPadmin;SourceDB=E:admin.dbc;SourceType=DBC;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;”
Set td = db.CreateTableDef(“dept”)
td.Connect = ConnectString
td.SourceTableName = “dept”
db.TableDefs.Append td
Set td = db.CreateTableDef(“personne”)
td.Connect = ConnectString
td.SourceTableName = “personne”
db.TableDefs.Append td
‘Following code is required because no primary key is defined on personne.
‘Without the following code, personne is read only.
Dim strSQL As String
strSQL = “CREATE INDEX pk_emp_no ON personne(emp_no) WITH PRIMARY”
Set dbs = DBEngine(0)(0)
dbs.Execute strSQL, dbFailOnError
End Sub
Thanks in advance,
Kevin