Prompt user to save changes in a form

  • Follow


Hello...
I figured out how to prompt my users to save their changes to an existing
record in a form before closing.  However, I was wondering how I can make it
so it only prompts them on existing records and not new.  Another words if
they create a new record and add in their data I do not want the prompt to
come up when they go to close the window.  I hope I am explaining this
correctly.  =)

Thank you in advance for any help you can give.  Also...fyi...I am not very
familiar with sql so I need the "dummy" version please =)

0
Reply amyr74 8/8/2007 9:32:04 PM

Sorry again, I dont know a whole about all this.  Were in VB do a paste this?
Sorry I know your probably laughing at me.  =)

This is what I have in the form so far

Private Sub Form_BeforeUpdate(Cancel As Integer)

    Dim LResponse As Integer
    Dim LMsg As String

LMsg = "!!WARNING!! You are about to change an existing record.  Do you wish
to save changes?"
LResponse = MsgBox(LMsg, vbYesNo, "Save changes")

If LResponse = vbNo Then
      DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70

End If

End Sub


SteveM wrote:
>Test the form's NewRecord property:
>
>If Not Me.NewRecord Then
>'Run code when not a new record
>End If
>
>Steve
>
>> Hello...
>> I figured out how to prompt my users to save their changes to an existing
>[quoted text clipped - 6 lines]
>> Thank you in advance for any help you can give.  Also...fyi...I am not very
>> familiar with sql so I need the "dummy" version please =)

0
Reply amyr74 8/8/2007 10:06:17 PM


"amyr74" <u36497@uwe> wrote in news:7667dc522c40a@uwe:

> Hello...
> I figured out how to prompt my users to save their changes to
> an existing record in a form before closing.  However, I was
> wondering how I can make it so it only prompts them on
> existing records and not new.  Another words if they create a
> new record and add in their data I do not want the prompt to 
> come up when they go to close the window.  I hope I am
> explaining this correctly.  =)
> 
> Thank you in advance for any help you can give. 
> Also...fyi...I am not very familiar with sql so I need the
> "dummy" version please =) 
> 
You do not need to prompt them. Access automatically saves any 
changes, whenever you close the form, or move to another existing 
or new record.


-- 
Bob Quintal

PA is y I've altered my email address.

-- 
Posted via a free Usenet account from http://www.teranews.com

0
Reply Bob 8/8/2007 10:23:30 PM

You missed the point, Bob. The OP wants to check and make sure that the user
actually wants to save the change(s) to the existing record! This is pretty
standard if an accidental change to data could create a critical problem.

As Steve said, you have to wrap your code so it only fires if the record
*isn't* a new record. You do that with 

If Not Me.NewRecord Then (if the record isn't a new record then do this code)
 
Private Sub Form_BeforeUpdate(Cancel As Integer)

   Dim LResponse As Integer
   Dim LMsg As String

If Not Me.NewRecord Then

LMsg = "!!WARNING!! You are about to change an existing record.  Do you wish
to save changes?"
LResponse = MsgBox(LMsg, vbYesNo, "Save changes")

If LResponse = vbNo Then
     DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70

End If

End If
End Sub

-- 
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200708/1

0
Reply missinglinq 8/9/2007 2:30:57 AM

Working like a peach, Thanks so much!!!!!!!!!!!!

missinglinq wrote:
>You missed the point, Bob. The OP wants to check and make sure that the user
>actually wants to save the change(s) to the existing record! This is pretty
>standard if an accidental change to data could create a critical problem.
>
>As Steve said, you have to wrap your code so it only fires if the record
>*isn't* a new record. You do that with 
>
>If Not Me.NewRecord Then (if the record isn't a new record then do this code)
> 
>Private Sub Form_BeforeUpdate(Cancel As Integer)
>
>   Dim LResponse As Integer
>   Dim LMsg As String
>
>If Not Me.NewRecord Then
>
>LMsg = "!!WARNING!! You are about to change an existing record.  Do you wish
>to save changes?"
>LResponse = MsgBox(LMsg, vbYesNo, "Save changes")
>
>If LResponse = vbNo Then
>     DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
>
>End If
>
>End If
>End Sub
>

-- 
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200708/1

0
Reply amyr74 8/9/2007 1:15:15 PM

4 Replies
1044 Views

(page loaded in 0.258 seconds)

Similiar Articles:
















7/20/2012 2:35:25 AM


Reply: