You cannot add or change a record because a record is required in header_generator

KWHAT

Registered User.
Local time
Today, 00:51
Joined
Dec 7, 2011
Messages
19
Hey guys ive been looking online and seeing a lot of comments about cascading deletes, Relationships and enforcing referential Integrity. However i still cannot find my error where i have went wrong, hopefully someone out there is quicker than me, by the way im new in Access. So here is a image of my relationships,
Relationships.png

So basically i have many tables main table is the Header_Generator which contains HG_ID and links it to all the the other tables, so my main goal was if i deleted a HG_ID it will delete the records related to this field everywhere. Saying that i had created two forms a parent form contains the HG_ID creation and the child form which contains the HEADER_ID, so when im in the parent form and i decide to manual delete this record and redirect to another form completely i get no error message and everything is working as suppose too. However i created a button to this manual step however since i've created this i get the error message i mentioned before
Code:
 You cannot add or change a record because a record is required in header_generator

if i avoid the message i can see the code does work, its just that error message so annoying, so this is my coding i have in VBA


Code:
'Delete current data and redirect to home screen.
 Private Sub DeleteEntry_Click()

'Promt
 strPrompt = "All windows created will be delete, are you sure you want to delete this entry?"
'Dialog's Title
 strTitle = "Warning"
'Display MessageBox
 iRet = MsgBox(strPrompt, vbYesNo + vbCritical, strTitle)


If iRet = 6 Then

    Me.USER.SetFocus
    DoCmd.RunCommand acCmdSelectRecord
    DoCmd.RunCommand acCmdDeleteRecord
    DoCmd.Requery
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.Close

    DoCmd.OpenForm "HOME", OpenArgs:=Permissions & "|" & UserName & ""
  Exit Sub

End If
End Sub

Overall i might be a lost case so help a brother out!!! Thank you!
 

Users who are viewing this thread

Back
Top Bottom