Hello Everyone,
I have this function working perfectly in AC2003 but not in AC2007 format
--------------------------------------------------------
Public Function fGetLinkPath(strTable As String) As String
Dim dbs As DAO.Database, stPath As String
Set dbs = CurrentDb()
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
-------------------------------------------------------------
When you call it from the open action:
------------------------------------------------------------
Private Sub Form_Open(Cancel As Integer)
Dim CurrPath As String
CurrentDb.TableDefs.Refresh
For Each loTd In CurrentDb.TableDefs
CurrPath = fGetLinkPath(loTd.Name)
Exit For
Next loTd
Set loTd = Nothing
If PathDBExist(CurrPath) = False Then
MsgBox "Path to database is invalid.Please Re-connect to the database", vbCritical + vbOKOnly, "CWORKS CMMS"
DoCmd.OpenForm "DataSource"
Exit Sub
End If
End Sub
-------------------------------------------------------------
Does anyone know what I need to do to make it work? It returns false each time thereby giving the msgbox info above. This shouldn't be because the file actually exist. Like I said, it works perfectly on .mdb but not on .accdb
Any help would be cvery much appreciated. I am not the author but found the code in one of the sample files I downloaded a long time ago form the net.
Thanks.
I have this function working perfectly in AC2003 but not in AC2007 format
--------------------------------------------------------
Public Function fGetLinkPath(strTable As String) As String
Dim dbs As DAO.Database, stPath As String
Set dbs = CurrentDb()
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
-------------------------------------------------------------
When you call it from the open action:
------------------------------------------------------------
Private Sub Form_Open(Cancel As Integer)
Dim CurrPath As String
CurrentDb.TableDefs.Refresh
For Each loTd In CurrentDb.TableDefs
CurrPath = fGetLinkPath(loTd.Name)
Exit For
Next loTd
Set loTd = Nothing
If PathDBExist(CurrPath) = False Then
MsgBox "Path to database is invalid.Please Re-connect to the database", vbCritical + vbOKOnly, "CWORKS CMMS"
DoCmd.OpenForm "DataSource"
Exit Sub
End If
End Sub
-------------------------------------------------------------
Does anyone know what I need to do to make it work? It returns false each time thereby giving the msgbox info above. This shouldn't be because the file actually exist. Like I said, it works perfectly on .mdb but not on .accdb
Any help would be cvery much appreciated. I am not the author but found the code in one of the sample files I downloaded a long time ago form the net.
Thanks.