Access Crashes When Trying To Set The Modern Web Browser Control’s Control Source Property Via Code

Software Bug

I was working on a little routine to update a demo file so it would reconfigure the Control Sources of the various Modern Web Browser control (MWBC) to match the database folder (same principle as relinking tables, I’m trying to relink MWBCs).

Public Function FixMWBCControlSources()
    On Error GoTo Error_Handler
    Dim oFrm                  As Access.Form
    Dim lCounter              As Long
    Dim oCtrl                 As Access.Control
    Dim oEdge                 As Access.Edge
    Dim sCS                   As String
    Dim sFile                 As String
    Dim bFrmUpdated           As Boolean

    For lCounter = 0 To CurrentProject.AllForms.Count - 1
        bFrmUpdated = False
        If CurrentProject.AllForms(lCounter).IsLoaded Then
            DoCmd.Close acForm, CurrentProject.AllForms(lCounter).Name, acSaveNo
        End If
        DoCmd.OpenForm CurrentProject.AllForms(lCounter).Name, acDesign
        Set oFrm = Forms(CurrentProject.AllForms(lCounter).Name)

        For Each oCtrl In oFrm.Controls
            If oCtrl.ControlType = acEdgeBrowser Then
                Set oEdge = oCtrl
                bFrmUpdated = True
                sCS = oEdge.ControlSource
                sCS = Replace(sCS, """", "")
                sCS = Replace(sCS, "=", "")
                sFile = GetFileName(sCS)
                oEdge.ControlSource = "=""https://msaccess/" & Application.CurrentProject.Path & "\" & sFile & """"
            End If
        Next oCtrl

        If bFrmUpdated Then
            DoCmd.Close acForm, CurrentProject.AllForms(lCounter).Name, acSaveYes
        Else
            DoCmd.Close acForm, CurrentProject.AllForms(lCounter).Name, acSaveNo
        End If
    Next lCounter

Error_Handler_Exit:
    On Error Resume Next
    Set oEdge = Nothing
    Set oCtrl = Nothing
    Set oFrm = Nothing
    Exit Function

Error_Handler:
    MsgBox "The following error has occurred" & vbCrLf & vbCrLf & _
           "Error Source: FixMWBCControlSources" & vbCrLf & _
           "Error Number: " & Err.Number & vbCrLf & _
           "Error Description: " & Err.Description & _
           Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
           , vbOKOnly + vbCritical, "An Error has Occurred!"
    Resume Error_Handler_Exit
End Function

It run up until it hits line

                oEdge.ControlSource = "=""https://msaccess/" & Application.CurrentProject.Path & "\" & sFile & """"

and Access crashes every time.

Needless to say, either I’m not seeing my error or we have another bug.

I consulted the documentation (the Edge Browser refers to the legacy Web Browser control documentation for this property!)

and sadly the content is inaccurate mentioning things like expressions with Date(), LastName…. obviously completely neglected and not written for the control upon which it is actually being used to support! That said it indicates the property is supposed to be Read/Write!

I tried sprinkling with DoEvents, adding a delay or 2, nothing worked. Access always crashes.

Heck, for fun, I even tried simply pushing the current value back to the control, effectively making no change at all, by doing:

                oEdge.ControlSource = oEdge.ControlSource

That resulted in the same behavior, Access crashing!

So needless to say, there is obviously a bug here!