[AccessD] Code Help Please

Joe Hecht joe at anamericanjoe.us
Fri Feb 29 08:20:09 CST 2008


The following code is supposed warn when the value of a particular text gets
changed. You almost never want the value changed after the record is
created.

 

 

Private Sub txtQBInvoice_BeforeUpdate(Cancel As Integer)

    If Me.txtQBInvoice = "" Then

        Else

    If Me.txtQBInvoice.Value <> Me.txtQBInvoice.OldValue Then

          Dim lngRetval As Long

 

  lngRetval = MsgBox( _

    "The Quick Books Invoice Number has changed." & vbCrLf & "" & vbCrLf &
"Do you want to change this Value?", _

    vbYesNo + vbExclamation + vbDefaultButton2, _

    "QB Invoice Number has been changed")

 

  Select Case lngRetval

    Case vbYes

        Me.txtQBInvoice.Value = Me.txtQBInvoice.Value

        

    Case vbNo

        Me.txtQBInvoice.Value = Me.txtQBInvoice.OldValue

   

   End Select

  

  End If

  End If

  

End Sub

 

I get error 2115  The Macro or function in the before update is preventing
access from saving the record.  This message occurs when I click the no
button and debug hilites the case vbNo.

 

What I want on the no click is for the value to be set to the old value and
move to the next field.

 

If this is a new record and there was no old value this check should not
run.

 

TIA

 

Joe Hecht

Joe at anamericanjoe.us

 




More information about the AccessD mailing list