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!

select items in listbox based on query

Status
Not open for further replies.

G00GLER

Instructor
May 17, 2005
57
0
0
US

basically I have a matrix, when a user enters in a fact, they catergorize it by legal theories. so when someone edit's this fact the listbox should select the items already associated with this item. If user makes changes by unselecting then update button would remove from the matrix all entries associated with FactId and re enter in the entries.

i posted this database on http://www.joinsthefamily.com/images/mdb.zip
the form that comes up shows works great it's the form UpdateFacts that has the problem
Code:
For i = 0 To Me.ListLegalTheories.ListCount - 1
    If Me.ListLegalTheories.ItemData(i) = Rst!LegalTheoryID Then
        Me.ListLegalTheories.Selected(i) = True
    End If
Next i
 
Solution:

Code:
    For i = 0 To Me.ListLegalTheories.ListCount - 1
    If DCount("[LegalTheoryID]", "Matrix", "[FactID] = " & DMax("[FACTID]", "FACTS") & " AND [LegalTheoryID]= " & Me.ListLegalTheories.ItemData(i)) > 0 Then
            Me.ListLegalTheories.Selected(i) = True
    End If
    Next i

Though this is a DCOUNT query the result for my purposes will always be one or zero, so true or false. Hopes this helps someone looking for similar situation in the future.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top