The code below captures a fully qualified archived file name from a combo box and inquires of the user whether it is to be ONLY viewed or used to restore the app's primary data. In preparation to moving the archived file to the app's principle folder, the primary backend file needs to be deleted. As can be seen in the screenshot, the FSO.DeleteFile fails because of permissions issue. With the "frmRegister" having been closed and the RowSource of the combo set to a zero length string, there shouldn't be any binding issues at hand, though my understanding is that FSO isn't affected even if some binding is present.
Code:Private Sub cboArchView_Click() Dim strArcFile As String Dim strViewChoice As String strArcFile = Me.cboArchView.Column(1) 'Capture whatever file name might have been selected strViewChoice = MsgBox(strArcFile & vbNewLine & _ "archive file selected. Do you want to " & vbNewLine & _ "RESTORE it as primary data? ""YES"" Or just" & vbNewLine & _ "open archive for viewing only ""NO"".", vbYesNoCancel) strArcFile = strArchFoldr & strArcFile Select Case strViewChoice Case vbYes Me.cboArchView.RowSource = "" 'Drop binding on combo SetAttr strArcFile, vbNormal DoCmd.Close acForm, "frmRegister" Set FSO = CreateObject("Scripting.FileSystemObject") Select Case strDataMode Case "Personal" FSO.DeleteFile strPerDB FSO.MoveFile strArcFile, strPerDB Case "Business" FSO.DeleteFile strBusDB FSO.MoveFile strArcFile, strBusDB End Select Case vbNo Call ReLink(strArcFile, True) MsgBox "Press function key ""F9"" when done" Case Else End Select Set FSO = Nothing Me.cmdViewArch.SetFocus Me.cboArchView.Visible = False End Sub
As one can observe in the following screenshot, where Debug shows the file name, that there must be some other issue rather than the name which I know to be valid.
What seems to be the problem with the FSO.DeleteFile?