Hello to anyone willing to help,
I’m currently making a database in Microsoft Access. I have a table, which has a Child table, where I use VBA to retrieve a file path from a file that exists on my computer and create a hyperlink to that file. The VBA code works for what it is intended, but the problem is that it only writes this to the first record of the master table, and not to a given other. How can I change this?
The code I’m using right now:
Private Sub Command187_Click() Dim varItem As Variant Dim obj As Object Dim rsimg As dao.Recordset Set obj = CreateObject("WScript.shell") Set rsimg = CurrentDb.OpenRecordset("Tbl_CompanyFiles", dbOpenDynaset) Set fdialog = Application.FileDialog(msoFileDialogFilePicker) With fdialog .AllowMultiSelect = True .Title = "Select Images To Add - Multiples OK" .InitialFileName = obj.specialfolders("desktop") .InitialView = msoFileDialogViewLargeIcons .Filters.Clear If .Show = True Then For Each varfile In .SelectedItems rsimg.AddNew rsimg("CompLinkedFilesName") = Right(varfile, Len(varfile) - InStrRev(varfile, "")) rsimg("CompLinkedFilesPath") = "#" & Right(varfile, Len(varfile)) & "#" rsimg.Update Next varfile End If End With
The field name it is supposed to write to is CompID, but I do not know how to implement this.