Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / May 2007

Tip: Looking for answers? Try searching our database.

Yes or No question on dirty

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nick - 15 May 2007 18:22 GMT
I would like to have a message pop up when data is changed in a form with the
action to follow.
I know it has something to do with the property of "On dirty"
If any control is changed in the "Employee" form is made, I should receive a
message stating " You have updated information on this record. Do you want to
save it?"  The answer of "Yes" or "No" is selected and the action should
happen with an exiting statment of "Update has been saved" or "update has not
been saved"
Klatuu - 15 May 2007 18:50 GMT
Use the form Before Update event:

   If Msgbox("Data Has Changed - Do You Want to Update this Record", _
           vbQuestion + vbYesNo) = vbNo Then
       MsgBox "Record Not Updated"
       Cancel = True
   End If

Now, we don't want to put the Updated message here, because the update has
not occurred.  That you should put in the After Update event.  You don't need
a question with it.  Just be sure it is placed so it will not show if an
error occurs:

Private Sub Form_BeforeUpdate()

   On Error GoTo NoUpdateError

   MsgBox "Record Updated"

   Exit Sub

NotUpdateError:

  MsgBox Err.Number & " " & Err.Description
End Sub
Signature

Dave Hargis, Microsoft Access MVP

> I would like to have a message pop up when data is changed in a form with the
> action to follow.
[quoted text clipped - 4 lines]
> happen with an exiting statment of "Update has been saved" or "update has not
> been saved"
Nick - 16 May 2007 07:01 GMT
I have inserted code stated in update event but receive this statment when
entering "NO" in text box. First I receive "Record Not Updated" then another
message box that states after clicking on the "OK" on "Record not updated";
"You can't go to the specified record" and it will not let me go to the next
record until I enter "Yes"  then it accept changes and allows me to go to the
next record
other wise it loops the statments
Where do I enter the statment listed  below?
I am very confused on this.
> Private Sub Form_BeforeUpdate()
>     On Error GoTo NoUpdateError
[quoted text clipped - 6 lines]
>
>    MsgBox Err.Number & " " & Err.Description

> Use the form Before Update event:
>
[quoted text clipped - 30 lines]
> > happen with an exiting statment of "Update has been saved" or "update has not
> > been saved"
Klatuu - 16 May 2007 13:15 GMT
I made a couple of mistakes, sorry.
First, I left out a line in the before update if the user answers no.  
Should be:

   If Msgbox("Data Has Changed - Do You Want to Update this Record", _
           vbQuestion + vbYesNo) = vbNo Then
       MsgBox "Record Not Updated"
       Cancel = True
       Me.Undo
   End If

The Undo will allow you to move to another record.

The other code should be in the After Update.

Private Sub Form_AfterUpdate()
   On Error GoTo NoUpdateError

   MsgBox "Record Updated"

   Exit Sub
NotUpdateError:

  MsgBox Err.Number & " " & Err.Description
End Sub
Signature

Dave Hargis, Microsoft Access MVP

> I have inserted code stated in update event but receive this statment when
> entering "NO" in text box. First I receive "Record Not Updated" then another
[quoted text clipped - 50 lines]
> > > happen with an exiting statment of "Update has been saved" or "update has not
> > > been saved"
Nick - 16 May 2007 16:00 GMT
Thanks, I am allowed to move to the next record when I answer "NO" but I
still receive the message box "you can't go to the Specified record" and when
entereing the code in the Private Sub Form_AfterUpdate() when I answer "Yes"
it goes to the compiler highliting the "On error got noupdateerror" with a
message box stating "Label no defined"

> I made a couple of mistakes, sorry.
> First, I left out a line in the before update if the user answers no.  
[quoted text clipped - 76 lines]
> > > > happen with an exiting statment of "Update has been saved" or "update has not
> > > > been saved"
Klatuu - 16 May 2007 16:40 GMT
The label is defined in the code I posted, but again, I have a syntax error.  
My brain was only at about 40% power yesterday, sorry

Private Sub Form_AfterUpdate()
   On Error GoTo NotUpdateError  <-reference to label

   MsgBox "Record Updated"

   Exit Sub
NotUpdateError:  <- label (must have colon)

Signature

Dave Hargis, Microsoft Access MVP

> Thanks, I am allowed to move to the next record when I answer "NO" but I
> still receive the message box "you can't go to the Specified record" and when
[quoted text clipped - 82 lines]
> > > > > happen with an exiting statment of "Update has been saved" or "update has not
> > > > > been saved"
Nick - 17 May 2007 07:34 GMT
Thanks! That did the trick.

> The label is defined in the code I posted, but again, I have a syntax error.  
> My brain was only at about 40% power yesterday, sorry
[quoted text clipped - 93 lines]
> > > > > > happen with an exiting statment of "Update has been saved" or "update has not
> > > > > > been saved"
Klatuu - 17 May 2007 13:25 GMT
Glad you got it working.
Again, my apologies for the syntax errors.
Signature

Dave Hargis, Microsoft Access MVP

> Thanks! That did the trick.
>
[quoted text clipped - 95 lines]
> > > > > > > happen with an exiting statment of "Update has been saved" or "update has not
> > > > > > > been saved"
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.