I have recently converted an Access front/back-end app into a SQL Server (2000) back-end database from a front-end MS Access (2003). The tables are linked via ODBC.
I want to add a new field to one of the tables in the back-end, via the front-end Access by VBA coding.
I have done it in the past by creating a tabledef and appending a field to that, but now when I try that to the SQL server, it doesn't work. Basically it goes to setting the database with the workarea and it breaks there. "set dbData = wrkArea.OpenDatabase.... (below)
Is there a specific way to append to SQL Server? or see something wrong in my connection code? Thanks in advance.
Expand|Select|Wrap|Line Numbers
- Dim wrkArea As Workspace
- Dim dbData As Database
- Dim tbl As TableDef
- Dim flds As Fields
- Dim fld As Field
- Dim strDest As String
- strDest = GetPath("tblStudents")
- Set wrkArea = DBEngine.CreateWorkspace("", "Admin", "sa", dbUseODBC)
- Set dbData = wrkArea.OpenDatabase(strDest, True)
- Set tbl = dbData.TableDefs("tblStudents")
- Set fld = tbl.CreateField("Termination", dbDate)
- tbl.Fields.Append fld
- dbData.Close
- wrkArea.Close