Results 1 to 2 of 2

Thread: Automatic save

  1. #1
    Join Date
    Nov 2003
    Posts
    16

    Unanswered: Automatic save

    HI,

    Im trying to search a database to determine if a record already exist, if it does i wan tot give the user the option of changin the existing record if the wants to. i made an event that propomt the user, if the user presses OK i want the form of the existing contact to [pop up so the user can change the info. However, my event is set to before update and when i try to go to the other record a runtime error occurs because i interfere with the automatic saving in Access. is there a way to disable automatic saving of records? Here is the code im using

    Private Sub last_name_BeforeUpdate(Cancel As Integer)

    Dim Name As Variant
    Dim strMsg2 As String
    Dim bytAnswer2 As Byte
    Dim id As Integer

    Name = DLookup("[last_name]", "tbl_Contact", "[last_name] = '" & Forms!frm_Contact!last_name & "' AND [first_name] = '" & Forms!frm_Contact!first_name & "'")

    id = DLookup("[RecordNumber]+0", "Contact_Name", "[last_name] = '" & Forms!frm_Contact!last_name & "' AND [first_name] = '" & Forms!frm_Contact!first_name & "'")

    If Name <> " " Then
    strMsg2 = "This Contact Already Exist. Would you like to Change the contact information?"
    bytAnswer2 = MsgBox(strMsg2, vbYesNo + _
    vbDefaultButton2 + vbQuestion)

    If bytAnswer2 = vbYes Then
    rien = MsgBox("Close this message box and then press ESC to cancel the changes", vbInformation)

    DoCmd.GoToRecord acDataForm, "frm_Contact", acGoTo, id


    ElseIf bytAnswer2 = vbNo Then
    rien = MsgBox("Close this message box and then press ESC to cancel the changes", vbInformation)
    DoCmd.CancelEvent

    End If

    End If

    End Sub

  2. #2
    Join Date
    Oct 2003
    Location
    US
    Posts
    343
    Use this after you are done updating the record.

    DoCmd.RunCommand acCmdSaveRecord

Posting Permissions

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