andy_dyer
Registered User.
- Local time
- Today, 06:07
- Joined
- Jul 2, 2003
- Messages
- 806
Hi
I've found an old thread called this same thing but it didn't quite work for me still and didn't want to post onto a 2 year old thread... so figured I'd start a new one... hope that is ok and I am staying the right side of the site admin's...
I have a cmd button on a form which if clicked i want it to check that i'm sure and if i clcik yes then delete the current record, then close the form returning me to another open form behind which has a summary datasheet which then should auto refresh to delete the line...
Then this on close
It is deleting the detail in the record but leaving the Primary Key (FinanceYearID) and the Foreign Key (ProjectID) hence when the datasheet requeries it leaves blank lines behind which look messy...
How can I get this to delete the whole record not just the data??
I'm using Access 2010 btw in case that makes a difference...
I've found an old thread called this same thing but it didn't quite work for me still and didn't want to post onto a 2 year old thread... so figured I'd start a new one... hope that is ok and I am staying the right side of the site admin's...
I have a cmd button on a form which if clicked i want it to check that i'm sure and if i clcik yes then delete the current record, then close the form returning me to another open form behind which has a summary datasheet which then should auto refresh to delete the line...
Code:
Private Sub cmdDeleteCurrentRecord_Click()
On Error GoTo Err_cmdDeleteCurrentRecord_Click
Dim Answer As Integer
Answer = MsgBox("Are you sure you wish to delete this record?", vbYesNo + vbExclamation + vbDefaultButton2, "Delete Confirmation")
If Answer = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.Close
DoCmd.SetWarnings True
Else
End If
Exit_cmdDeleteCurrentRecord_Click:
Exit Sub
Err_cmdDeleteCurrentRecord_Click:
MsgBox Err.Description
Resume Exit_cmdDeleteCurrentRecord_Click
End Sub
Then this on close
Code:
Private Sub Form_Close()
Forms![frmprojectfinanceyear].SetFocus
Forms![frmprojectfinanceyear].[frmFinanceYear].Requery
Forms![frmprojectfinanceyear].[frmProjectSummaryData].Requery
End Sub
It is deleting the detail in the record but leaving the Primary Key (FinanceYearID) and the Foreign Key (ProjectID) hence when the datasheet requeries it leaves blank lines behind which look messy...

How can I get this to delete the whole record not just the data??
I'm using Access 2010 btw in case that makes a difference...