Hi Guys,
Generally new to VBA and had a long piece of code I simply wanted copied to a bunch of different 'AfterUpdate' properties for combo boxes (have hundreds of these combo boxes in my form).
I'm having to repeat the same long code to each one, and if I update the code then I have to manually go through to every 'AfterUpdate' and add in that piece. I'm hoping to have it one place as some kind of routine, and simply refer to that routine with a single word/line in each property.
The code is fairly simple, I'm just setting up variables and assigning them the value from a lookup column. Here's the code for reference;
-------------------------------------------
Code:
Dim PurchaseCamARig As Currency
Dim PurchaseCamACam As Currency
Dim PurchaseCamALens1 As Currency
Dim PurchaseCamALens2 As Currency
Dim PurchaseCamAMedia As Currency
Dim CostCamARig As Currency
Dim CostCamACam As Currency
Dim CostCamALens1 As Currency
Dim CostCamALens2 As Currency
Dim CostCamAMedia As Currency
PurchaseCamARig = Me.cmb1stCamARig.Column(2)
PurchaseCamACam = Me.cmb1stCamACam.Column(2)
PurchaseCamALens1 = Me.cmb1stCamALens1.Column(2)
PurchaseCamALens2 = Me.cmb1stCamALens2.Column(2)
PurchaseCamAMedia = Me.cmb1stCamAMedia.Column(2)
CostCamARig = Me.cmb1stCamARig.Column(3)
CostCamACam = Me.cmb1stCamACam.Column(3)
CostCamALens1 = Me.cmb1stCamALens1.Column(3) * Me.txt1stCamALens1Q
CostCamALens2 = Me.cmb1stCamALens2.Column(3) * Me.txt1stCamALens2Q
CostCamAMedia = Me.cmb1stCamAMedia.Column(3)
Me.txt1stCamAPurchaseSubTotal = PurchaseCamARig + PurchaseCamACam + PurchaseCamALens1 + PurchaseCamALens2 + PurchaseCamAMedia
Me.txt1stCamACostSubtotal = CostCamARig + CostCamACam + CostCamALens1 + CostCamALens2 + CostCamAMedia
---------------------------------------------------
Thanks for any help!