I have a horse database with the following fields:
Horse_id
Name
Sire
Dam
Born
Died
Gender
Sample Data
-----------------
Horse_id - 10
Name - Black
Sire - 20
Dam - 30
Born - 2000
Died - 0
Gender - S
What I am trying to do is on the form (frmHorses) when you click the "rubbish bin" to delete that record, it checks the Horse_id with all the records of Sire and Dam.
This is so that the Horse can not be deleted if it is the Sire or Dam of an existing horse.
However the code is not letting me delete any horses,
For the sample data above this should delete this record, but it does not.
Thanks for you help
This is the code for "rubbish bin" (delete record)
If DCount("Sire", "horse", "horse_id =" & Me.txtHorse_id. Value) >= 0 Then
If DCount("Dam", "horse", "horse_id =" & Me.txtHorse_id. Value) >= 1 Then
End If
MsgBox "A horse can not be deleted if it is the Sire or Dam of an existing horse"
Else
DoCmd.DoMenuIte m acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuIte m acFormBar, acEditMenu, 6, , acMenuVer70
End If
Horse_id
Name
Sire
Dam
Born
Died
Gender
Sample Data
-----------------
Horse_id - 10
Name - Black
Sire - 20
Dam - 30
Born - 2000
Died - 0
Gender - S
What I am trying to do is on the form (frmHorses) when you click the "rubbish bin" to delete that record, it checks the Horse_id with all the records of Sire and Dam.
This is so that the Horse can not be deleted if it is the Sire or Dam of an existing horse.
However the code is not letting me delete any horses,
For the sample data above this should delete this record, but it does not.
Thanks for you help
This is the code for "rubbish bin" (delete record)
If DCount("Sire", "horse", "horse_id =" & Me.txtHorse_id. Value) >= 0 Then
If DCount("Dam", "horse", "horse_id =" & Me.txtHorse_id. Value) >= 1 Then
End If
MsgBox "A horse can not be deleted if it is the Sire or Dam of an existing horse"
Else
DoCmd.DoMenuIte m acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuIte m acFormBar, acEditMenu, 6, , acMenuVer70
End If
Comment