Subscribe now and choose from over 30 free gifts worth up to £49 - Plus get £25 to spend in our shop
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
Not that I know of.
<ever helpful me>
<and I do use Access and VBA loads>
Wouldn't adding a 'check total' button to the form do?
Agreed ^. You need to monitor for 10 events, so 10 event handlers.
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.
Thanks guys
