Don't allow AfterUpdate in Combo Box

Posted on 2011-10-13
Last Modified: 2012-05-12
I have an AfterUpdate action in a combo box that works just fine. Now, I am needing to first check to see if there is a value in a text box before running the AfterUpdate code.

Combo box name: OverrideLetterType
Text box name: DateLetterSent

Basic logic needed: If IsNull(DateLetterSent) Then
Run the code to override letter type
show a message box saying "You can't override a letter type that has already been sent"
End If

Thanks for any suggestions.
Question by:dlogan7
    LVL 61

    Expert Comment

    Its very close to what you have written.

    In your After Update event:

    If NOT IsNull(DateLetterSent) Then
       MsgBox "You can't override a letter type that has already been sent"
        exit sub
    End If
    ' Your After update code follows here

    LVL 84
    Or use Nz:

    If Nz(Me.DateLetterSent, "") <> "" Then
      Msgbox "blah"
      '/ Your AU code
    End If
    LVL 61

    Accepted Solution

    However... do you want to actually cancel/undo the combo box's update?  If so your check belongs in the BEFORE update event like this:

    Private Sub OverrideLetterType_BeforeUpdate(Cancel as Integer)
    If NOT IsNull(DateLetterSent) Then
       MsgBox "You can't override a letter type that has already been sent"
       Cancel = true
    End If
    End Sub


    Or if you simply want to prevent the user from using theis combo box after a letter has been sent,  you can conditionally lock it down.

    If that is something that fits your needs you would need code in the the current event of your form as well as whatever event sends the letter as follows:

    Me.OverrideLetterType.Locked = NOT IsNull(DateLetterSent)


    Author Closing Comment

    You know you're good when you can answer a question that requires you to read the submitter's mind. I do want to UNDO the combo box's update. Perfect. Thanks.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    TaskManager all tabs values are 0% 4 42
    MsgBox 2 29
    Subform Link field 13 20
    Passing a TempVar to a Combo box form 3 24
    In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now