For my internship, I've to link specific objects (tblObject, fldObject) to files (tblFiles, fldFiles) with the corresponding numbers. So let's for example say the object is TM002, if there is a file with the name 'TM002.jpg', it will link automatically when you press a button and put them into tblObjectFile.
The problem I have is that I have to link around 143,000 files and when I press the button, it only connects 18,000 of them.
Code:Private Sub cmdLink_Click() Dim vDB As DAO.Database Dim vRST As DAO.Recordset Dim strSQLObject As String Dim strSQLFiles As String Set vDB = CurrentDb strSQLObject = "SELECT * from tblobject order by objectnumber" Set vRST = vDB.OpenRecordset(strSQLObject, dbOpenDynaset, dbSeeChanges) vRST.MoveFirst Do While Not vRST.EOF strSQLFiles= "INSERT INTO tblObjectFile (fldobjectid,fldFileID)" strSQLFiles = strSQLFiles & " SELECT " & vRST!objectid & ", fldFileID FROM tblfile where instr(fldfile," & Chr(34) & vRST!Objectnumber & Chr(34) & ") >0 " DoCmd.SetWarnings False DoCmd.RunSQL strSQLFiles vRST.MoveNext Loop End Sub