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

x
?
Solved

Before Update Event in Combo Box Cancel event

Posted on 2009-12-22
3
Medium Priority
?
801 Views
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."
        Me.Client_ID.Undo
        Cancel = True
    End If
End Sub


Before-Update-Error.JPG
Before-Update-Error2.jpg
0
Comment
Question by:dpokerbear
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
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.
0
 

Author Closing Comment

by:dpokerbear
ID: 31669995
thanks.
0
 
LVL 39

Expert Comment

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

Happy computing!

Nelson
0

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