none
Kill statement not working on web browser control file RRS feed

  • Question

  • Access 2016. I have a form with a WebBrowser control named “WBControl” with =[TxtFileLoc] as its ControlSource

    I am able to locate the file (.pdf) I need and then attach it by running a query. But I can’t get the Kill statement to work:

    This is how the WebBrowser control looks before I begin running any code:

    The “Browse PDFs” button has the following code:

    Dim strSourceFolderName As String

            strSourceFolderName = Me!TxtFileLoc

            Set myfile = Application.FileDialog(msoFileDialogFilePicker)

            myfile.AllowMultiSelect = False

            If myfile.Show Then

                Me.TxtFileLoc = myfile.SelectedItems.Item(1)

            End If

    This is how my WebBrowser control looks after running BrowsePDFs and AttachPDFs until the Kill statement error message comes up.

    The Attach PDF’s button has the following code:

    Dim myfile As FileDialog

        mYN = MsgBox("Do You Want to Delete the Source File Now?", vbExclamation + vbYesNo, "USW")

        'Yes=6    No=7

        If mYN = 6 Then

            Me!TxtFileLoc = ""

            Kill (strSourceFolderName)

    OR

            Kill (Me![TxtFileLoc])

            DoEvents

            Me!WBControl.ControlSource = Me!TxtFileLoc

        End If

    Everything works well until the Kill statement. I have tried looking all over the web with no luck.

    This is the error message:

    I think I will have to return the WebBrowser control to its initial “blank” state. How can I accomplish this??? What references will I have to set to successfully do this?

    Saturday, November 16, 2019 9:14 PM

All replies