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)


            Kill (Me![TxtFileLoc])


            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

  • The error message indicates a permission issue, so one of 2 thoughts come to me

    • You can 't delete files in that folder
    • It is locked because you are viewing it.

    Daniel Pineault, 2010-2019 Microsoft MVP
    Professional Support: http://www.cardaconsultants.com
    MS Access Tips and Code Samples: http://www.devhut.net

    Saturday, November 16, 2019 10:38 PM