How can I limit the records in a List box.

jimkerry

New member
Local time
Today, 04:42
Joined
Jan 29, 2010
Messages
9
[FONT=&quot]I have a List box on a sub-form which will find records on the sub form based on the value selected in the list box but want to limit the records available in the List box to the Child field on the sub form that is matched to the Master field on the main form.[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]Can I adapt the code on the form - "[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] Set rs = Me.Recordset.Clone
rs.FindFirst "[WH_BlocksAssetId] = " & Str(Nz(Me!
[List0], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]" somehow to accomplish this.[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]
The Child/ Master field is called UPRN.[/FONT]
 
Put that in a loop and count until you get to the desired number of records. Reassign the recordset to the subform. Requery.
 
Thanks VBA..

It's not the nr of records I'm trying to manage -I'm trying to select (limit) the records for the List where the data in the linked field on the main form/ sub-form (child/ master field) are the same or are identical.
 
Two ways I can think of.

1. Open the recordset of the listbox, which is its rowsource. Use the Filter method of the recordset, then set that recordset's as the rowsource of the listbox.

2. Or what I normally do is, alter the SQL to include a WHERE clause and set it back. An unbound listbox would work better so all you do is add and remove from the list.
 

Users who are viewing this thread

Back
Top Bottom