Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2012

    Unanswered: AfterUpdate Event VBA question involving checkbox and Combobox

    I am trying to write VBA codes for an AfterUpdate event involving a numeric value, a checkbox, and a combobox.

    Thre are three fields.

    fieldone is a numeric value in a form. It was an automatically calculated value in a form using an AfterUpdate event.
    fieldtwo is a checkbox.
    fieldthree is a combobox with "Y" and "N".

    Condition for fieldthree to display "Y" automatically: fieldone needs to be highter than 10 and fieldtwo needs to be checked (True)

    Any other option, I would like fieldthree to display "N".

    The following is what I've tried so far.

    Question1: Do I need to do AfterUpdate event for both fieldone and fieldtwo?
    or just for fieldthree.
    Question2: The following codes doesn't seem to work. Please offer some idea. Thanks.

    Private Sub fieldthree_AfterUpdate()

    If (fieldone >= 10 And fieldtwo.Value = True) Then fieldthree.Value = "Y"
    Else: fieldthree.Value = "N"

    End Sub

  2. #2
    Join Date
    Jan 2012
    As you have explained it you will need AfterUpdate events for both fields. These events can be replicated and should read as follows for both fields:

    If Me.FieldOne.Value > 10 And Me.FieldTwo= -1 Then
    Me.FieldThree.Value = "Y"
    Me.FieldThree.Value = "N"
    End If
    Am slightly confused as to why FieldOne and FieldThree need to be enabled on the form? If they are both calculated fields then by my thinking this means that the user should only be making changes to your checkbox. If this is the case you would only need to run the AfterUpdate event on the checkbox as this is the only field that would be subject to change in form view.
    Hope this helps,



    Access 2000 User

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts