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 Programming / April 2006

Tip: Looking for answers? Try searching our database.

OldValue Property Not Working

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lorraine - 07 Apr 2006 18:35 GMT
When the value in textbox TypeID is updated I want there to be a Warning
through a message box.  If the user clicks the "No" button I want there to be
an automatic "undo" of the change.  

The message box displays and the Yes button functions, but when the No
button is selected I get a run-time error '2115' that states "The macro or
function set to the BeforeUpdate or ValidationRule property for this field is
preventing Microsoft Access from saving the data in the field."  I don't have
a ValidationRule property set for this field.

Private Sub TypeID_BeforeUpdate(Cancel As Integer)
OriginalValue = TypeID.OldValue

RetValue = MsgBox("You are about to CHANGE or DELETE a TypeID.  Are you sure
you want to do this?", 260 + vbCritical, "WARNING")

If RetValue = vbNo Then

    For Each ctlTextbox In Me.Controls
    If TypeID.ControlType = acTextBox Then
       TypeID.Value = TypeID.OldValue
    End If
    Next ctlTextbox

End If
End Sub

In the nested If-Then statement, the TypeID.Value is capturing the updated
value and the TypeID.OldValue is capturing the value before update but this
is the line of code that is also being highlighted by the debugger.

Help me please.
Signature

Lorraine

Mr B - 07 Apr 2006 20:16 GMT
Lorraine,

I tried some of the BeforeUpdate event things, but did not have a lot of
success. I then tried the following:

Assuming that the "OriginalValue" is a variant type variable, then try:

Place the assignment of the current value to the variable to the On Enter
event of the control:
Private Sub TypeID_Enter(Cancel As Integer)
    OriginalValue = TypeID.OldValue
end sub

The in the After Update event of the control:
Private Sub TypeID_AfterUpdate()
If Me.TypeID.Text <> OrignialValue Then
   RetVal = MsgBox("Want to do this?", vbYesNo)
   If RetVal = vbNo Then
       'Cancel = True
       'Me.TypeID.Undo
       Me.TypeID = OrignialValue
   End If
End If
End Sub

This worked for me.

Signature

HTH

Mr B

> When the value in textbox TypeID is updated I want there to be a Warning
> through a message box.  If the user clicks the "No" button I want there to be
[quoted text clipped - 28 lines]
>
> Help me please.
Lorraine - 07 Apr 2006 21:54 GMT
Mr B,

I had to modify your code a bit by

#1 Omitting the "Cancel as Integer" argument in the TypeID_Enter Sub
Procedure.

#2 Needed to declare the variable "OriginalValue" as an Integer in the
module level so that the variable could be read between the TypeID_Enter and
the TypeID_AfterUpdate procedures.

It works beautifully now.

Thanks!
Signature

Lorraine

> Lorraine,
>
[quoted text clipped - 55 lines]
> >
> > Help me please.
 
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



©2008 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.