[AccessD] Code Help Please

Arthur Fuller fuller.artful at gmail.com
Fri Feb 29 15:50:31 CST 2008


I'm not sure, Joe, but since you only have two choices, you could either
replace the Select Case approach with an If/Else/End If or just change the
second Case to Case Else. Either should work as you want.

hth,
Arthur

On Fri, Feb 29, 2008 at 6:20 AM, Joe Hecht <joe at anamericanjoe.us> wrote:

> 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