Calculation using listboxes

JaredNJames

Registered User.
Local time
Today, 06:55
Joined
Jul 7, 2007
Messages
87
Hi, i have to list boxes, List2 and List4 which are updated from a query.

does anyone know how to get it so that when i click calculate, the value in List2 is taken from the value in List4, giving me a quantity.

the value has to go into a text box

any ideas welcomed

jared james
 
You can use this code as an example: -

Dim tmpvalA As Long
Dim tmpvalB As Long

'first check which value is selected in ListA
x = 0

Do Until x > Me.List4.ListCount
If Me.List4.Selected(x) Then
tmpvalA = Val(Me.List4.ItemData(x))
End If
x = x + 1
Loop

'now check which value is selected in ListB
x = 0

Do Until x > Me.List6.ListCount
If Me.List6.Selected(x) Then
tmpvalB = Val(Me.List6.ItemData(x))
End If
x = x + 1
Loop

' Only calculate if both values are greater than zero
If tmpvalA <> 0 And tmpvalB <> 0 Then
Me.Text8.SetFocus
Me.Text8.Text = tmpvalA - tmpvalB
End If
 

Users who are viewing this thread

Back
Top Bottom