Dynamically populate a list box

D

Dheinze57

I use several cmdbuttons to open to open a customer form frmCust with a where
clause in VBA

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmCust"
stLinkCriteria = "[status id]=3"
DoCmd.OpenForm stDocName, , , stLinkCriteria

(Status ID per each cmdbutton is 1 = Active, 2 = Inactive, 3 = Deceased, etc.)

I use a ListBox to then select a record for data entry. It is based on the
underlying query.

SELECT [qryCust].[Lastname] FROM [qryCust];

This displays all the underlying [lastname]s, but obviously many are not in
the current recordset.

The problem is: How do I populate the list box based on the current
recordset of the form in VBA.
 
Top