T
Todd
I have code on a continuous form that lists all documents related to a
particular client. Each row of the form has a field that contains a
hyperlink to the associated file [Link]. I created a button that would
delete the record and the corresponding file. The code gets an error
messgae when it gets to the 2nd "DoCmd" line. It asks me if I'm sure that I
want to delete the record. I click "yes" and then I get the message... "No
current record" and the file is not deleted because the code has stopped.
Any idea why I'm getting this message? Am I missing something simple? Here
is the code...
Private Sub delfile_Click()
On Error GoTo Err_Delete_File_and_Link_Click
Dim strFile As String
Dim length As Integer
'DELETE FILE LINKED
'Remove # signs from link
length = Len([Link])
strFile = Left([Link], length - 1)
strFile = Right(strFile, length - 2)
'Delete record
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
'Test and delete file
Debug.Print strFile
Kill (strFile)
Exit_Delete_File_and_Link_Click:
Exit Sub
Err_Delete_File_and_Link_Click:
MsgBox Err.description
Resume Exit_Delete_File_and_Link_Click
End Sub
particular client. Each row of the form has a field that contains a
hyperlink to the associated file [Link]. I created a button that would
delete the record and the corresponding file. The code gets an error
messgae when it gets to the 2nd "DoCmd" line. It asks me if I'm sure that I
want to delete the record. I click "yes" and then I get the message... "No
current record" and the file is not deleted because the code has stopped.
Any idea why I'm getting this message? Am I missing something simple? Here
is the code...
Private Sub delfile_Click()
On Error GoTo Err_Delete_File_and_Link_Click
Dim strFile As String
Dim length As Integer
'DELETE FILE LINKED
'Remove # signs from link
length = Len([Link])
strFile = Left([Link], length - 1)
strFile = Right(strFile, length - 2)
'Delete record
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
'Test and delete file
Debug.Print strFile
Kill (strFile)
Exit_Delete_File_and_Link_Click:
Exit Sub
Err_Delete_File_and_Link_Click:
MsgBox Err.description
Resume Exit_Delete_File_and_Link_Click
End Sub