|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Hi guys, the following 2 peices of code work fine only if the other doesn't exist!
The first is to ask if the user wants to save the changes before updating the form. If i say "yes", everything works fine. but if i say "No", i get the error msg "You cant go to the specified record", and problem is shown with the following line in subroutine Refresh_Click(): DoCmd.GoToRecord , , acNewRec Private Sub Form_BeforeUpdate(Cancel As Integer) Dim strMsg As String strMsg = "Data has changed." strMsg = strMsg & "Do you wish to save the changes?" If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then 'do nothing Else DoCmd.RunCommand acCmdUndo End If End Sub Private Sub Refresh_Click() DoCmd.GoToRecord , , acNewRec cboSize2.Visible = True cboRun_pipe.Visible = True txtSchedule2.Visible = True End Sub |
|
#2
|
||||
|
||||
|
you can't undo something that hasn't been saved yet. Put that in the afterupdate.
__________________
Did I help you? If so gimme rep by clicking on the at the top right corner of this post ![]() Madness does not always howl. Sometimes, it is the quiet voice at the end of the day saying, "Hey, is there room in your head for one more?" |
|
#3
|
|||
|
|||
|
Quote:
Hi ben, thanks for ur reply. I'm afraid putting that code in after update is not solving the problem. It's jus displays an extra msgBox which tells the user that "you are about to delete a record. continue?" and again the same issue on selecting "Yes" |
|
#4
|
|||
|
|||
|
If I remember correctly you simply want to set Cancel = True in your beforeUpdate to cancel the update.
|
|
#5
|
|||
|
|||
|
Quote:
hi, thanks for ur reply, yup that works .. added this code to my cmd button refresh. If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Changes?") = vbYes Then ' do nothing Else cancel = True Me.Undo End If |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft Access Help > Forms - Problem with Form_before update event |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|