Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004
    Posts
    90

    Unanswered: How can I prompt to save.

    I have a form with many records of different people. Now the company that I am doing this work for wants me to prompt them to save each record if it has been modified when they click to go to the next record. Now I know that forms already automatically save when you make a change but I guess they are having problems with people changing the data and not knowing it. (Don't ask me).. So does someone know how I can prompt the user to save a record if it has been modified when they click to go to the next (or previous) record? Thanks

  2. #2
    Join Date
    Aug 2004
    Location
    Netherlands
    Posts
    2
    Before saving current record the event BeforeUpdate is called:

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    End Sub

    Here you can check whether the record is changed (.Dirty)

    Bolukan

  3. #3
    Join Date
    Nov 2003
    Posts
    1,487
    For Example:


    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    	If Me.Dirty = True Then
    	 If MsgBox("This record has been changed or editied." & vbNewLine & _
    		"Do you want to Save these changes or Undo" & vbNewLine & _
    		"them? [Yes = Save] [No = Undo]", vbQuestion + vbYesNo, _
    		"Record Changed") = vbYes Then
    		Exit Sub
    	 Else
    		Dim ctlC As Control
    		'For each control.
    		On Error Resume Next
    		For Each ctlC In Me.Controls
    			If ctlC.ControlType = acTextBox Then
    			'Restore Old Value.
    			ctlC.Value = ctlC.OldValue
    			End If
    		Next ctlC
    	 End If
    	End If
    End Sub

  4. #4
    Join Date
    May 2004
    Posts
    90
    That worked perfectly. Thank you!

Posting Permissions

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