Calculate value by using two combo box values

Scythed

Registered User.
Local time
Today, 10:08
Joined
Aug 30, 2008
Messages
28
Currently what I have is Four cascading combo boxes. IT starts with a minimum value and a maximum value. Depending upon what you choose you then get to choose the name. And depending on the name you get the colour. I want to make it so once you choose the colour it will tell you the exact price of that item. This is what I have so far, it accurately shows the price of the item in the rowsource of the combo box Test. But what I want to do is make it so that it displays the price of the item in a text box. I am new at visual basic so please bear with me :). Thank You.


Private Sub ComboColour_AfterUpdate()
On Error Resume Next
Test.RowSource = "Select RollID.[Sale Price] " & _
"FROM RollID " & _
"WHERE RollID.CarpetName = '" & ComboCarpetName.Value & "' " & _
"AND RollID.Colour = '" & ComboColour.Value & "' " & _
"ORDER BY RollID.Colour;"
ColourLabel.Caption = ComboColour.Value


End Sub
 
how i get you is that your ordering steps are :
Value , Name , Color , Price
so how you should look at it is that at your last stage which is Color combo box (Your final stage of ordering) should be your concluding stage (price calculation) and thus updating your price output control whatever control you pick for it (I'd go for Text Box).
And thus try for Color Combo box the following :

Private Sub ComboColour_GetFocus()
On Error Resume Next
ComboColour.RowSource = "Select RollID.[Colour] , RollID.[Sale Price] " & _
"FROM RollID " & _
"WHERE RollID.CarpetName = '" & ComboCarpetName.Value & "' " & _
"ORDER BY RollID.Colour;"
End Sub

Set Column Count to 2
Set Bound Column to 1
Set Column Width to 10cm;0cm <-- That would lead column 2 to appear hidden

And thus what realy should happen on AfterUpdate would be:
Private Sub ComboColour_AfterUpdate()
On Error Resume Next
ColourLabel.Caption = ComboColour.Value
Me![Test] = Me![ComboColour].Column(1) '<--- Notice column() function use index mean of count which starts by 0 (so price column 2 would be of index 1)
End Sub

Best Regards,
nIGHTmAYOR
 
Thank you very much it worked like a charm :) really appreciate it
 

Users who are viewing this thread

Back
Top Bottom