prompt not to delete if there is value in subform

zxmax

Registered User.
Local time
Today, 02:51
Joined
Mar 14, 2004
Messages
16
Greeting
i have a main form with a subform
the subform value has "ID" value with a relationship with the the main form

now if i delete a record from the main Form, the records in my subform will have no value to relate to

i do have a Delete Button in my main form , so what i want is, when the Delete Button is pressed, Check if there is any records in my Subform, and not to allow me to delete unless i move these records from the Subform

here is my current Code for the Delete button
------------------------------
Private Sub Command47_Click()
On Error GoTo Err_Command47_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_Command47_Click:
Exit Sub

Err_Command47_Click:
MsgBox Err.Description
Resume Exit_Command47_Click

End Sub
------------------------

any help on modifying this Delete Button, or any work around ?
(basically , what i want is to have the records in my Subform Moved to a different "ID" in my main Form before deleting the main Form "ID"

thanks
 
Turn on Referential Integrity between these two tables!
 
Perfect,
thanks :)
 

Users who are viewing this thread

Back
Top Bottom