Forum Discussion

Rodster's avatar
Rodster
Copper Contributor
Mar 11, 2022

Update hyperlink addresses for a recordset using VBA

Greetings VBA Access gurus,

 

I am trying to find the correct code to firstly list the existing target addresses for a recordset of hyperlinks, and then to update the address to a new SharePoint address...

 

This was my first and unsuccessful attempt:

 

Private Sub cmdHyperlinkList_Click()

Dim myDB As DAO.Database
Dim rst As DAO.Recordset
Dim strTable As String
Dim intRecords As Integer, i As Integer


strTable = "HyperlinkTest"
Set myDB = CurrentDb()
Set rst = myDB.OpenRecordset(strTable, dbOpenTable)
rst.Index = "PrimaryKey"
rst.MoveLast
rst.MoveFirst
intRecords = rst.RecordCount

For i = 1 To intRecords

rst.Edit
rst("HyperlinkAddress") = rst("NetworkFolderLocation").Hyperlink.Address
rst.Update

rst.MoveNext

Next i
Set rst = Nothing
Set myDB = Nothing

DoCmd.OpenTable strTable, acViewNormal, acReadOnly

End Sub

 

The line in blue is causing the problem 

 

 

Any help from anyone would be much appreciated.

 

Thanks

Resources