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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with List box

Status
Not open for further replies.

rbasram

Programmer
Sep 27, 2001
53
0
0
CA
This what I have, it is function in my on_click on my form where the two listboxes are. All I am tring to do is passing the products from one listbox one by one in the dcount fuction and then adding the result to another listbox on the same form.

For intItem = 0 To Me!lstAllProduct.ListCount - 1

Totals = DCount("[Product]", "Bulletins", "[Product]= '" & Me![lstAllProduct] & "'")

Totals = Totals + 1

lststr = CStr(Totals) & IIf(intItem = 0, "", ";" & lststr)

Me!txtSequence.RowSource = lststr

Next intItem

The problem is that My Dcount fuction is working only when i manually select the product in the lstAllProduct that is I have to first select the product (itemselected property then only it knows which product to pass through dcount fuction and insert the result into the other listbox. What am I doing wrong. Is there a way that the fuction can automatically select the list and then pass the products one by one into the for loop.
Please help...
 

Insert the following code after the For statement

Me!lstAllProduct.Selected(intItem) = True

Hope this helps
 
try putting the code on the OnOpen Event! i believe that the function is only counting when you click on the lstbox!
also, try to put a "." instead of a "!", like this:

Me.lstAllProduct.ListCount

do the same thing for the rest of the xclamation points!

hope it helps!

Skep :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top