OpenDatabase-fejl
Jeg prøver med følgende funktioner at opdatere min backend DB, men i min OpenDatabase-linie får jeg en Type-mismatch fejl. Hvis man laver en Debug.Print fGetLinkPath("t_adgang") returnerer den sti og filnavn på Backend databasen. Er der nogen, der kan se, hvad der er galt?_______________________________________________
Function UpdateTableFieldDefns() As Boolean
Dim dbsUpdate As database, wrkDefault As Workspace
Dim tdfUpdate As TableDef, tdfField As Field
Dim strMsg As String, intResponse As Integer, strSQL As String
Dim idxUpdate As Index, idxField As Field
Dim prpNew As Property, relNew As Relation
Dim tdfTable1 As TableDef, tdfTable2 As TableDef
Dim StrBackend As String
UpdateTableFieldDefns = False
Set wrkDefault = DBEngine.Workspaces(0)
' Add new fields and tables to backend
CurrentDb.TableDefs.Refresh
StrBackend = fGetLinkPath("t_adgang")
Set dbsUpdate = wrkDefault.OpenDatabase(fGetLinkPath("t_adgang"), True)
Debug.Print dbsUpdate
'......
UpdateTableFieldDefns = True
End Function
____________________________________________________________
Public Function fGetLinkPath(StrTable As String) As String
Dim dbs As database, stPath As String
Set dbs = CurrentDb()
' Set StrTable = t_adgang
On Error Resume Next
stPath = dbs.TableDefs(StrTable).Connect
If stPath = "" Then
fGetLinkPath = vbNullString
'can change this to currentdb.name
Else
fGetLinkPath = Right(stPath, Len(stPath) - (InStr(1, stPath, "DATABASE=") + 8))
End If
Set dbs = Nothing
End Function
