Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Sub ChangeConnect(strDBpath As String, strOldpath As String, strNewpath As String)
'strDBpath Path and File Name of database that you want to update links in.
'strOldpath Path you want to replace
'(or other element in connect property you want to change)
'strNewpath Path replacement (or Replacement element
Dim Ws As DAO.Workspace
Dim Db As DAO.Database
Dim tbls As DAO.TableDefs
Dim tbl As DAO.TableDef
Dim strconnect As String
Dim intStartpos As Integer
Dim intlenoldpath
Set Ws = DBEngine.Workspaces(0)
Set Db = Ws.OpenDatabase(strDBpath)
Set tbls = Db.TableDefs
intlenoldpath = Len(strOldpath)
For Each tbl In tbls
strconnect = tbl.Connect
If Len(strconnect) > 0 Then
intStartpos = InStr(1, strconnect, strOldpath, vbTextCompare)
If intStartpos > 0 Then
strconnect = Left(strconnect, (intStartpos - 1)) & strNewpath & Right(strconnect, (Len(strconnect) - intStartpos - intlenoldpath + 1))
'MsgBox tbl.Connect & Chr(13) & Chr(13) & strconnect
tbl.Connect = strconnect
tbl.RefreshLink
tbls.Refresh
'MsgBox tbl.Connect
End If
End If
Next
Db.Close
Set tbl = Nothing
Set tbls = Nothing
Set Db = Nothing
Set Ws = Nothing
End Sub
Option Compare Database
Option Explicit
[COLOR=green]'*** Stolen from:
'*** [URL unfurl="true"]http://www.ammara.com/access_image_faq/recursive_folder_search.html[/URL][/color]
Private m_strDirectoryName As String
Public Property Get DirectoryName() As String
DirectoryName = m_strDirectoryName
End Property
[COLOR=green]'Usage Example:
' Dim colFiles As New Collection
' RecursiveDir colFiles, "C:\Photos", "*.jpg", True
'
' Dim vFile As Variant
' For Each vFile In colFiles
' Debug.Print vFile
' Next vFile
'
'
'Output:
'C:\Photos\2006-10-28\IMG_2851.JPG
'C:\Photos\2006-10-28\IMG_2852.JPG
'C:\Photos\2006-11-04\IMG_2853.JPG
'C:\Photos\2006-11-04\IMG_2854.JPG
'C:\Photos\2006-11-04\IMG_2855.JPG[/color]
Public Function RecursiveDir(colFiles As Collection, _
strFolder As String, _
strFileSpec As String, _
bIncludeSubfolders As Boolean)
On Error Resume Next
Dim strTemp As String
Dim colFolders As New Collection
Dim vFolderName As Variant
[COLOR=green] 'Add files in strFolder matching strFileSpec to colFiles[/color]
strFolder = TrailingSlash(strFolder)
strTemp = Dir(strFolder & strFileSpec)
If Err = 52 Then strTemp = ""
Do While (strTemp <> vbNullString) And (strTemp > "")
colFiles.Add strFolder & strTemp
strTemp = Dir
Loop
If bIncludeSubfolders Then
[COLOR=green] 'Fill colFolders with list of subdirectories of strFolder[/color]
strTemp = Dir(strFolder, vbDirectory)
If Err = 52 Then strTemp = ""
Do While (strTemp <> vbNullString) And (strTemp > "")
DoEvents
If (strTemp <> ".") And (strTemp <> "..") Then
If (GetAttr(strFolder & strTemp) And vbDirectory) <> 0 Then
colFolders.Add strTemp
End If
End If
strTemp = Dir
Loop
m_strDirectoryName = strFolder
[COLOR=green] 'Call RecursiveDir for each subfolder in colFolders[/color]
For Each vFolderName In colFolders
Call RecursiveDir(colFiles, strFolder & vFolderName, strFileSpec, True)
Next vFolderName
End If
End Function
Public Function TrailingSlash(strFolder As String) As String
If Len(strFolder) > 0 Then
If Right(strFolder, 1) = "\" Then
TrailingSlash = strFolder
Else
TrailingSlash = strFolder & "\"
End If
End If
End Function