Figuring different calculations per choice in combo box

patentinv

Registered User.
Local time
Today, 13:32
Joined
Aug 29, 2005
Messages
29
Hello, I have a combo box called (cboridge) bound to a table called (Ridge)with two fields/columns called (dollar amount) (Material type)with 4 different options/records, when the user selects his option/field the dollar amount shows stays visible in the (cboridge) combo box Then I have a text box called (txtridgetot) that has a calculation in it, but I need different calculations per option/field that's picked. Can each option/record that is chosen have a different calculation associated with it in the (txtridgetot) text box.

In other words if the user selects the third option/field called shake ridge could I have a calculation that would run and have it display the sum of this calculation in the text box (txtridgetot).

If so could you please describe how?

Thanks-- Any help will be greatly appreciated.
 
Do it in the AfterUpdate event of the ComboBox something like:
Code:
Private Sub cboridge_AfterUpdate()
Select Case Me.cboridge.Column(1)

   Case "Tile"
      Me.txtridgetot = Me.SubTotal + Val(Me.cboridge.Column(0)
   Case "Steel"
      Me.txtridgetot = Me.SubTotal + Val(Me.cboridge.Column(0)
   Case "Shake"
      Me.txtridgetot = Me.SubTotal + Val(Me.cboridge.Column(0)
   Case "The 4th Choice"
      Me.txtridgetot = Me.SubTotal + Val(Me.cboridge.Column(0)
End Select
End Sub
 
Hi RG, I really struggle with VB code, Sorry. Here's the calculation I have in the txtridgetot box now in the control source=([txtridge]*100/30)+0.4 [txtridge] is another text box on my from, if you would could you give me an example of how this calculation would fit into your example code?
Case "Tile"
Me.txtridgetot = Me.SubTotal + Val(Me.cboridge.Column(0)

Thanks--I appreciate your help
 
Actually you do not need code in the ComboBox after all. Just change the formula in txtridgetot to:

=(([txtridge]+Nz(Val(Me.cboridge.Column(0)),0))*100/30)+0.4
or...
=(([txtridge]*100/30)+0.4)+Nz(Val(Me.cboridge.Column(0)),0)

Depending on how you want to do the math.
 
Thanks RG,
I don't think this will work, beacause each diifferent option/record in the combobox needs a slightly different calculation, I had a combo box for each selection but it clutters the form up w/unnecessary boxes. So I'm stuck wanting to use only 1 combobox, w/a different calculation per option.
The value/source dollar amount that shows in the combo box is not used in this calculation. I'll use it in another text box that will multiply textridgetot * cboridge, which will be the actuall cost of this material for the specific bid/estimate. However I need to get textridgetot populated correctly first.

Thanks--for all the help.
 
Hi RG, I figured it outw/a little help.
Here's the code
Dim prp As Property, ctl As Control

Set prp = Me!cboRidge.Properties("ListIndex")
Set ctl = Me.txtRidgetot

If prp = 0 Then
ctl = ([txtridge]*100/30)+0.4
ElseIf prp = 1 Then
ctl = ([txtridge]*100/45)+0.4
ElseIf prp = 2 Then
ctl = ([txtridge]*100/20)+0.4
Else
ctl = ([txtridge]*100/25)+0.4
End If

Set ctl = Nothing
Set prp = Nothing

Thanks-- for your help I appreciate it.
 
That's excellent! So you didn't need any $ amount from the cbo, just which formula to use?
 

Users who are viewing this thread

Back
Top Bottom