Results 1 to 2 of 2

Thread: warning message

  1. #1
    Join Date
    Sep 2007

    Unanswered: warning message

    OK! something Very weird is happening to my Close and Delete routine.

    I have been using the following 2 routine to delete record with multiple for several apps. I don't have any problem until now. Cannot figure out what is wrong with it and I hope someone will be able to tell me what did I do wrong.

    First, when a user Click the Close button. It will called up the cmdClose_Click. If the user choose to NOT save the record into the database, the Delete routine will be called out. Well, all is well. The Delete routine delete all the appropriate record in all the table. However, It keeps give me a warning

    " The field "tblContractItem.ContractID" cannot contain a Null value because the Required property for this field is set to True. Enter a value in this field" with a "OK" and "help" button.

    I can see why because I have deleted the record. However, I thought I have set the warning message to false. Do not understand why this warning keep popping up.
    Any help is greatly appreciated.
    Private Sub cmdClose_Click()
    DoCmd.SetWarnings False

    On Error GoTo Err_cmdClose_Click

    If MsgBox(" Would you like to commit this Contract into the database?", vbYesNo) = vbNo Then
    Call cmdDelete_Click
    DoCmd.Close acForm, "frmContractNEW", acSaveNo
    DoCmd.Close acForm, "frmContractAddNEW"


    Call cmdSave_Click

    DoCmd.Close acForm, "frmContractNEW", acSaveNo
    DoCmd.Close acForm, "frmContractAddNEW"
    End If

    Exit Sub

    MsgBox Err.Description
    Resume Exit_cmdClose_Click

    End Sub


    Private Sub cmdDelete_Click()

    On Error GoTo Err_cmdDelete_Click

    Dim db As Database
    Dim rs1 As DAO.Recordset
    Dim rs2 As DAO.Recordset

    Set db = CurrentDb()

    '-----open the tblContractItemPayment table and delete the old entries

    Set rs2 = db.OpenRecordset("Select * FROM tblContractItemPayment ", dbOpenDynaset, dbSeeChanges, dbOptimistic)

    If Not rs2.EOF Then


    Do Until rs2.EOF
    If rs2.Fields(0) = Forms!frmContractNEW!ContractID Then
    End If

    End If
    Set rs2 = Nothing
    '-----open the tblContractItem table and delete the old entries

    Set rs1 = db.OpenRecordset("Select * FROM tblContractItem ", dbOpenDynaset, dbSeeChanges, dbOptimistic)

    If Not rs1.EOF Then


    Do Until rs1.EOF
    If rs1.Fields(0) = Forms!frmContractNEW!ContractID Then
    End If

    End If
    'close the recordset


    ' release the memory back to the system

    Set rs1 = Nothing
    Set db = Nothing

    DoCmd.SetWarnings False

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

    Exit Sub

    MsgBox Err.Description
    Resume Exit_cmdDelete_Click

    End Sub
    Last edited by sweetmail; 10-04-09 at 09:25.

  2. #2
    Join Date
    Mar 2007
    In what form is this code located and what is the RecordSource of this form?
    RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP, ac07, ac10 - WinXP Pro, Win7 Pro
    Please reply to this forum so all may learn.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts