Hi
I have a delete button on my main form -which will delete a record from the main and subforms.
However when I try and add an additional record I get the error message:
You cannot add or change a record because a related record is required in table <name>. (Error 3201)
The record I have deleted is not present in any of the tables, the form is empty as if I had just opened it for input. I am eventually able to enter records but have to click to get rid of a message box telling me a related record is required about 10 times!!
The code behind the Delet button is:
Private Sub Command244_Click()
On Error Resume Next
DoCmd.SetWarnings False
Dim stDocName As String
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Do you really want to delete this record?" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "Record Delete" ' Define title.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
stDocName = "Q_Deleterec"
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
stDocName = "Q_Deleterec"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Else ' User chose No.
MyString = "No" ' Perform some action.
End If
End Sub
Can someone please tell me how I can stop this happening?
thanks a lot
F.
I have a delete button on my main form -which will delete a record from the main and subforms.
However when I try and add an additional record I get the error message:
You cannot add or change a record because a related record is required in table <name>. (Error 3201)
The record I have deleted is not present in any of the tables, the form is empty as if I had just opened it for input. I am eventually able to enter records but have to click to get rid of a message box telling me a related record is required about 10 times!!
The code behind the Delet button is:
Private Sub Command244_Click()
On Error Resume Next
DoCmd.SetWarnings False
Dim stDocName As String
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Do you really want to delete this record?" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "Record Delete" ' Define title.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
stDocName = "Q_Deleterec"
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
stDocName = "Q_Deleterec"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Else ' User chose No.
MyString = "No" ' Perform some action.
End If
End Sub
Can someone please tell me how I can stop this happening?
thanks a lot
F.