Hello, Im kinda new and im using access 07 and I want to delete images outside the DB. I have form (frmVWI) with a subform (frmVWISubform)and I they have a relationship and linked child fileds. The subform is a continious form that shows images and saves the images link to a table so it can show on my form. If I add a delete button on my form it delets all records accociated with that record and thats what I want except it doesnt delete the images from my image folder. I do however have a button on each row in the continious subform that is a delete button and it uses a "Kill" process that delets the image. How can i incorporate that into my other button? Here is the code for the one that delets the single image. I found most of the code on the net so I really dont know how the "kill" works. Thanks!
Thanks,
SoggyCashew.....
Code:
Private Sub cmdImg_Remove_Click()
On Error GoTo Err_cmdImg_Remove_Click
Dim Msg, Msg2, Style, Style2, Title, Response
Dim dbPath
dbPath = Application.CurrentProject.Path
' save the current image in case user changes mind
OriginalImagePath = Me!ImagePath
' set the variables for the message boxes
Msg = "Remove image?" & Chr(13) & Chr(13) & "Will delete file: " & Chr(13) & Chr(13) & dbPath & OriginalImagePath
Style = vbYesNo + vbQuestion + vbDefaultButton2
Msg2 = "No image to remove"
Style2 = vbOKOnly + vbInformation
Title = "Image Removal"
' make sure there is a photo there to remove
If IsNull(Me!ImagePath) Then
' no photo exists, so let the user know one cannot be removed
MsgBox Msg2, Style2, Title
Else
' a photo exists, so ask whether user is sure
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
' user wants to remove, so remove photo
Me![ImagePath] = ""
Me!imgJobStep.Picture = ""
Kill (dbPath & OriginalImagePath) 'deletes image in VWI_Images folder
Me.Requery 'Refresh form
txtUnboundImagePath.Requery 'Refresh text box
Else
' user wants to keep, so restore originial
Me![Image] = OriginalImagePath
Me!imgJobStep.Picture = dbPath & Me![Image]
End If
End If
Exit_cmdImg_Remove_Click:
Exit Sub
Err_cmdImg_Remove_Click:
Msg = "Error # " & Str(Err.Number) & Chr(13) & Err.Description
MsgBox Msg, vbOKOnly, "Bacterial Pathogenesis", Err.HelpFile, Err.HelpContext
Resume Exit_cmdImg_Remove_Click
End Sub
Thanks,
SoggyCashew.....