kaylachris
Registered User.
- Local time
- Today, 05:57
- Joined
- Jun 9, 2010
- Messages
- 10
I'm attempting to delete records from multipule tables with a single command button. However, I've so far been unsuccessful at getting it to work properly. My code doesn't throw any errors but it also doesn't actually delete the records either. I'm not posting the entire code simply because its repetative and is the same action w/ different TBLs and also deleted my comments to make the post a bit shorter but will provide them if needed. I'm stumped... I'm certain I'm overlooking something rather simple but can't put my finger on it. Thanks in advance 
Background:
FRM_Main
-searchSSN (combobox thats populated from TBL_PRIMARY, 2 columns (Name, SSN) bound column2 returns SSN)
-Delete (cmd button to delete all records associated with SSN from searchSSN)
TBL_PRIMARY (contains personal information name, etc... primary key SSN)
TBL_PRIMARY_APFT (contains multipule records with the same SSN linked to TBL_PRIMARY by SSN)
Edit: FRM_Main is an unbound form that acts as a switch

Background:
FRM_Main
-searchSSN (combobox thats populated from TBL_PRIMARY, 2 columns (Name, SSN) bound column2 returns SSN)
-Delete (cmd button to delete all records associated with SSN from searchSSN)
TBL_PRIMARY (contains personal information name, etc... primary key SSN)
TBL_PRIMARY_APFT (contains multipule records with the same SSN linked to TBL_PRIMARY by SSN)
Code:
Private Sub Delete_Click()
On Error GoTo Err_Delete_Click
If MsgBox("Are you sure you want to delete this record?", vbYesNo) = vbYes Then
CurrentDb.Execute "DELETE * FROM TBL_PRIMARY_APFT WHERE SSN = " & Me.searchSSN, dbFailOnError
CurrentDb.Execute "DELETE * FROM TBL_PRIMARY WHERE SSN = " & Me.searchSSN, dbFailOnError
MsgBox "Record has been successfully removed"
End If
Exit_Delete_Click:
Exit Sub
Err_Delete_Click:
MsgBox Err.Description
Resume Exit_Delete_Click
End Sub
Edit: FRM_Main is an unbound form that acts as a switch
Last edited: