Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stop Update event on condition

Status
Not open for further replies.

rfoye

Programmer
Oct 15, 2004
40
US
I have a numeric field that I want to clear if a research "flag" field is True. I put the following code in the BeforeUpdate event, but it is not halting the update. What have I left out?

Code:
Private Sub txtNewPayment_BeforeUpdate(Cancel As Integer)
    If optResearch = True And ((Not IsNull(txtNewPayment) Or txtNewPayment = "")) Then
        MsgBox "You can not add a payment for an account marked Research", , "Research"
        Cancel = True
        Me!txtNewPayment.Undo
        Me.Undo
    End If
End Sub


-------------------
Rob Foye
Database Management
Regions Bank
 
Maybe Exit Sub after your msgbox or where ever you want the code to stop.
 
You wanted something like this ?
If optResearch = True And Trim(txtNewPayment & "") <> "" Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I know I'd feel foolish when I discovered the answer to this, since I've done this before.

In case anyone wonders, the solution I was looking for was
DoCmd.CancelEvent

-------------------
Rob Foye
Database Management
Regions Bank
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top