• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • Last Modified:

Don't allow AfterUpdate in Combo Box

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
Else
show a message box saying "You can't override a letter type that has already been sent"
End If

Thanks for any suggestions.
0
Dale Logan
Asked:
Dale Logan
  • 2
1 Solution
 
mbizupCommented:
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

0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Or use Nz:

If Nz(Me.DateLetterSent, "") <> "" Then
  Msgbox "blah"
Else
  '/ Your AU code
End If
0
 
mbizupCommented:
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"
   Me.OverrideLetterType.Undo
   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)



0
 
Dale LoganConsultantAuthor Commented:
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.
0

Featured Post

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now