0

I have the following code:

    Private Sub Go_to_Link_Click()


On Error GoTo err_Go_to_Link_Click
        Application.FollowHyperlink [Forms]![frmMain_Menu]![subfrmRouting_Instructions]![TxtWebsite]
Exit_Go_to_Link_Click:
    Exit Sub
err_Go_to_Link_Click:
    MsgBox "Error Number: " & Err.Number & vbCrLf & "Error Description: " & Err.Description & vbCrLf & vbCrLf & "Shipping Website address is invalid, please inform customer service so they can update the URL in the routing guide"
    Dim rs As DAO.Recordset
    Dim freight_pack As String
    Dim Account_No As String
    Account_No = [Forms]![frmMain_Menu]![ComboAcctNum]
    freight_pack = [Forms]![frmMain_Menu]![ComboFreight_Packages]
    Set rs = CurrentDb.OpenRecordset("tblInvalid_URLs")
    rs.AddNew
        rs("Acct_Number") = Account_No
        rs("Shipping_Type") = freight_pack
        rs("Invalid_Shipping_Website_Link") = [Forms]![frmMain_Menu]![subfrmRouting_Instructions]![TxtWebsite]
        rs("Date_detected") = Now()
    rs.Update
    Resume Exit_Go_to_Link_Click

End Sub

Essentially what is happening here is there is a main form where the user selects the account number and ship type. these selections then populate a subform that contains all the shipping data needed for a specific account number and shipping type (freight or parcels).

On the subform, the user clicks a button to open a hyperlink that takes them to the required shipping website (fedex.com, ups.com, etc...). If the hyperlink is bad and triggers an error then it informs the user, and adds the accountnumber, shipping type, URL (that triggered error), and the current date to a log table so that people can run a report to see which URLs need updating.

I was curious, is it possible to loop through all the URLs in my main table to check if the hyperlinks are valid without actually opening each hyperlink? I essentially want to log all the bad URLs in one go vs logging them individually as our shipping guys encounter them so that I can generate a report and send it to the powers that be who are responsible for updating the URLs and what not.

Tom Newton
  • 91
  • 1
  • 6
Tbure90
  • 9
  • 5
  • What would determine a URL is "bad" if there is no attempt to execute it? How would "bad" URLs for shippers ever get saved in first place? – June7 Jun 06 '23 at 17:06
  • @June7 all the data used in my database is from an excel spreadsheet that our customer service team controls and updates. I was tasked with making a database to streamline the shipping information for our shipping team. Using UPS as an example, if in the spreadsheet they put the URL as "www.ups.com", i get an error saying the hyperlink can't be opened. instead you would have to put the full URL (https://www.ups.com/us/en/Home.page). That's how "bad" shipper URLs get saved, there could also be typos or a URL used to be valid but the shipping company could've changed their website or whatever – Tbure90 Jun 06 '23 at 18:10

0 Answers0