Viewing 6 posts - 1 through 6 (of 6 total)
  • VBA Help – "_AfterUpdate" event for mulitple controls on Access form
  • agentdagnamit
    Free Member

    I’ve got an Access Form with about 10 text boxes containing numbers that add up to a total value held in an 11th text box. I then need to check the value in textbox11 to make sure it doesnt exceed another value (held in box 12).

    I’ve attached code to each of the 10 text boxes to update the total in 11, but there must have been an easier way than this:

    Private Sub txtInitialDrop1_Vol_AfterUpdate()
    Call fCheckInitialVolume
    End Sub

    Private Sub txtInitialDrop2_Vol_AfterUpdate()
    Call fCheckInitialVolume
    End Sub

    Private Sub txtInitialDrop3_Vol_AfterUpdate()
    Call fCheckInitialVolume
    End Sub

    Private Sub txtInitialDrop4_Vol_AfterUpdate()
    Call fCheckInitialVolume
    End Sub

    etc etc

    Is there a way I can use just one _AfterUpdate event, by referencing all 10 text boxes as some sort of Collection maybe?

    cheers

    annebr
    Free Member

    Not that I know of.

    <ever helpful me>

    <and I do use Access and VBA loads>

    plop_pants
    Free Member

    Wouldn’t adding a ‘check total’ button to the form do?

    crankman
    Free Member

    Agreed ^. You need to monitor for 10 events, so 10 event handlers.

    SprocketJockey
    Free Member

    I’m not sure there is a way around having an update event on each textbox but an alternative to your approach you could call your code to run on the form’s afterupdate event rather than that of the individual text boxes and then simply put a me.refresh in the afterupdate event of the individual text boxes.

    Only real advantage of this over what you’re doing already though is that you only need to maintain the reference to your total check in one place rather than 10.

    agentdagnamit
    Free Member

    Thanks guys

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘VBA Help – "_AfterUpdate" event for mulitple controls on Access form’ is closed to new replies.