Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Figuring different calculations per choice in combo box 2

Status
Not open for further replies.

Patentinv

Technical User
Aug 26, 2005
84
US
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.
 
If I understand your question right:

In the AfterUpdate of cboRidge -

Code:
Me.txtRidgetot = cboRidge.Column(0) [i][Whatever your calculation is][/i]
Above is assuming that your source for cboRidge has the dollar amount as the first value.
 
Hi dcurtis, 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 form, if you would could you give me an example of how this calculation would fit into your example code? The value/source dollar amount that shows in the 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.

Me.txtRidgetot = cboRidge.Column(0) [Whatever your calculation is]

Also since there are 4 different records/options in the combo box each one will have a slightly different calculation. ([txtridge]*100/30)+0.4 the 100/30 maybe 100/45
or 100/25 etc, but almost the same calculation.

Thanks--I appreciate your help
 
How are ya Patentinv . . .

In the [blue]AfterUpdate[/blue] event of the combobox try this:
Code:
[blue]   Dim prp As Property, ctl As Control
   
   Set prp = Me!cboRidge.Properties("ListIndex")
   Set ctl = Me.txtRidgetot
   
   If prp = 0 Then
      ctl = [green]Calculation 1[/green]
   ElseIf prp = 1 Then
      ctl = [green]Calculation 2[/green]
   ElseIf prp = 2 Then
      ctl = [green]Calculation 3[/green]
   Else
      ctl = [green]Calculation 4[/green]
   End If
   
   Set ctl = Nothing
   Set prp = Nothing[/blue]

Calvin.gif
See Ya! . . . . . .
 
TheAceMan1's solution will do exactly what you are looking for, and it's cleaner that what I was typing....

Thanks Ace!
 
Hi AceMan1, I'm doing good now that you have solved another
one my road blocking programming problems.
How are you doing?
Thank you very much for your expert help. Your solution works perfectly. You have saved my night, again.

Thanks again--I really appreciate your time and help.

Thanks--dcurtis for all your help also. I don't know what I would do without you guys. Have a good night.

Chuck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top