If I'm reading this right, You have a table with names. Those names correspond to photo names, in a particular folder, and the extensions may not all be the same.
You want to import the paths to those photos and match them to the names in the table. You have a large number of photos so you want to do it in bulk.
You can use the GetBasename method of FileScriptingObject to do this.
Code:
Sub UpdateFiles2Table(strFolder As String)
Dim strSql As String
Dim fil As File
Dim fldr As Folder
Dim db As DAO.Database
If strFolder = "" Then Exit Sub
Set db = CurrentDb
Dim fso As New FileSystemObject
Set fldr = fso.GetFolder(strFolder)
For Each fil In fldr.Files
strSql = "Update Table2 set h = """ & fil.Path & """ where b = """ & fso.GetBaseName(fil.Path) & """"
Debug.Print strSql
db.Execute strSql, dbFailOnError
Next
Set fso = Nothing
Set db = Nothing
End Sub
You would call it with something like this:
Code:
Sub GetEm()
UpdateFiles2Table ("C:\Users\DANESH\Downloads\Telegram Desktop\photos")
End Sub
GetBaseName returns the filename without the extension so it will match the name with the filename.
This procedure loops through the folder and updates your table with the filepath where the Name matches the basename.
EDIT: You need to set a reference to Microsoft Scripting Runtime