Hello, I have two problems and cant figure out whey they dont work now.
First, I have a form with a subform and on the subform there is a delete button that is suposed to delete an image "If there is one" and then the record. The subform is a continious subform.
Whats happening is when I click the delete button on a record that includes an image everything works like its suposed to but if I click on a record that doesnt include an image it does nothing, it wont even delete the record. Can someone please show me whats missing or incorrect in the VBA.
Second, I have a delete button on the form and it deletes the record and its records that are accociated with the record. When I click the button it seems as if it did nothing but in fact it deletes the images associated with the record BUT doesnt delete the record.
I have a form with a subform and on the subform there is a delete button that is suposed to delete an image "If there is one" and then the record. The subform is a continious subform.
Whats happening is when I click the delete button on a record that includes an image everything works like its suposed to but if I click on a record that doesnt include an image it does nothing, it wont even delete the record. Can someone please show me whats missing or incorrect in the VBA.
Thanks,
SoggyCashew.....
First, I have a form with a subform and on the subform there is a delete button that is suposed to delete an image "If there is one" and then the record. The subform is a continious subform.
Whats happening is when I click the delete button on a record that includes an image everything works like its suposed to but if I click on a record that doesnt include an image it does nothing, it wont even delete the record. Can someone please show me whats missing or incorrect in the VBA.
Code:
Private Sub cmdDeleteStep_Click()
Dim strMsg As String
Dim dbPath
'Finds BE path in module-modGetPath
dbPath = GetCurrentPath()
OriginalImagePath = Me!ImagePath
strMsg = "Are you sure you want to delete this Job Step?" & Chr(13) & _
"" & Chr(13) & _
"" & _
"This job step and image will be deleted if (Yes) is selected!!!"
If MsgBox(strMsg, vbCritical + vbYesNo) = vbYes Then
Me![ImagePath] = ""
Me!imgJobStep.Picture = ""
'If Len(Dir(dbPath & OriginalImagePath)) > 0 Then 'Check to see if there is an image
Kill (dbPath & OriginalImagePath) 'If so then delete it.
'End If
DoCmd.RunCommand acCmdDeleteRecord ' Delete the record
Forms![frmVWI]![frmVWISubform].Requery ' Refresh subform
End If
End Sub
Second, I have a delete button on the form and it deletes the record and its records that are accociated with the record. When I click the button it seems as if it did nothing but in fact it deletes the images associated with the record BUT doesnt delete the record.
Code:
Private Sub cmdKillDelete_Click()
Dim rst As DAO.Recordset
Dim strSQL As String
Dim strDeleteVWI As String
Dim dbPath
Dim strPasswd
If IsNull(Me.txtVWIID) Then
MsgBox "There is no data or record to delete!", vbInformation, "No Data"
Exit Sub
End If
If MsgBox("Are you sure you want to delete this record?" & _
"There is no way to recover this if you say 'Yes'.", vbQuestion + vbYesNo, "Confirm Delete Record") = vbYes Then
'Finds BE path in module-modGetPath
dbPath = GetCurrentPath()
strSQL = "Select * From tblJobSteps Where VWIID = " & Me!VWIID
Set rst = CurrentDb.OpenRecordset(strSQL)
Do Until rst.EOF
If Dir(dbPath & rst!ImagePath) <> "" Then 'Verifies if image path is there
Kill (dbPath & rst!ImagePath) 'Deletes Image in folder /VWI_Images
End If
rst.MoveNext
Loop
'Deletes record from tblJobSteps
strSQL = "Delete * From tblJobSteps Where VWIID = " & Me!txtVWIID
CurrentDb.Execute strSQL, dbFailOnError
'Deletes record from tblVWI
strDeleteVWI = "Delete * From tblVWI Where VWIID = " & Me.txtVWIID
CurrentDb.Execute strDeleteVWI, dbFailOnError
Me.Requery
MsgBox "Deletion Complete", vbInformation, "Delete Confirmed"
DoCmd.Close 'Close the frmVWI
rst.Close
Set rst = Nothing
End If
End Sub
I have a form with a subform and on the subform there is a delete button that is suposed to delete an image "If there is one" and then the record. The subform is a continious subform.
Whats happening is when I click the delete button on a record that includes an image everything works like its suposed to but if I click on a record that doesnt include an image it does nothing, it wont even delete the record. Can someone please show me whats missing or incorrect in the VBA.
Thanks,
SoggyCashew.....