Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Before Update Event in Combo Box Cancel event

Posted on 2009-12-22
Medium Priority
Last Modified: 2013-11-28
This is my code and attached are examples of errors I get.
Statement "Cancel = True" is causing the problem.

Error1 happens only in this example, but Error2 happens in all my combo boxes on various forms throughout the project where I have Cancel = True in the Before Update Event.

Private Sub Client_ID_BeforeUpdate(Cancel As Integer)

    If Nz(DLookup("[Client ID]", "[tblAttendance]", "[Session ID] = " & _
        Nz(Forms![frmSessionAttendance].Form.Recordset.[Session ID], 0) & _
        "AND [Client ID] = " & Nz(Me.[Client ID], 0)), 0) <> 0 Then
        MsgBox "This client already exists on this list."
        Cancel = True
    End If
End Sub

Question by:dpokerbear
  • 2
LVL 39

Accepted Solution

thenelson earned 2000 total points
ID: 26111549
If you cancel the before update event of a control then you also need to cancel the form before update event and handle the form undo event. See  www.thenelson.name/#ReportFormTricks, "Check for required items" for details on how to do it.

Author Closing Comment

ID: 31669995
LVL 39

Expert Comment

ID: 26123653
You're welcome.  Glad to help and thank you very much for the points with "A" grade!

Happy computing!


Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Beware when using the ListIndex and the Column() properties of a listbox in Access 2007.  A bug has been identified in the Access 2007 listbox code which can cause the .ListIndex property to return a -1, and the .Columns(#) property to return a NULL…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question