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!

Help with Mulit-Select List Boxes

Status
Not open for further replies.

DanSc0tt

MIS
Sep 17, 2001
30
0
0
DE
Hi am trying to populate a list box based on a criteria set by another 'multi'-select list box. This is the first time i have tried to do this and put together the following code, but it is telling me that i have an 'invalid use of null' (where i try to bing back ProdURC from rs)

Can anybody help please??

Thanks!

Dim i As Integer, varItm
Dim strArray() As String
Dim x As Integer
Dim strRows As Variant



i = 0
With Me.lstCat
ReDim strArray(.ItemsSelected.Count - 1)
For Each varItm In .ItemsSelected
strArray(i) = .ItemData(varItm)
i = i + 1
Next varItm
End With


For x = 0 To i - 1
Dim rs As Recordset
Set rs = New Recordset
rs.LockType = adLockOptimistic
rs.Open "SELECT tblProduct.ProdURC, tblProduct.ProdNam, tblProduct.ProdDesc, tblProduct.ProdCat, tblProduct.ProdMotPartNum FROM tblProduct WHERE (((tblProduct.ProdCat)='" & strArray(x) & "'));", CurrentProject.Connection
rs.AddNew
Next x

If Not rs.EOF Then rs.MoveFirst

Do While Not rs.EOF

lst14.AddItem rs!ProdURC
rs.MoveNext

Loop
 
Would be of help - but this solution is in DAO and not ADO!
 
ah fixed it myself - autonumber was enabled! hence giving me a null entry in the final row of the recordset!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top