list box based on current recordset

G

Guest

I use several cmdbuttons to open the same form frmCust to display records. I
open the form with the following:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmCust"
stLinkCriteria = "[StatusID] = 1"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Each cmdbutton has the stLinkCriteria = "[StatusID] = ?" changed. ? = 1 for
Active, 2 for Inactive, 3 for Deceased, etc.

Once the form is open I use a list box to go to specific records. The
problem is the list box is based on the original form and reads:

SELECT [qryCust].[Full name] FROM [qryCust];

How can I limit the list box to only display the records in the current
recordset of the form?

Thanks!
 
A

AkAlan via AccessMonster.com

in the query you use to poulate the combo box just add a criteria to the
StatusId column that is equal to frmCust StatusId. It would look like this:
[Forms]![frmCust ]![StatusId ]
I use several cmdbuttons to open the same form frmCust to display records. I
open the form with the following:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmCust"
stLinkCriteria = "[StatusID] = 1"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Each cmdbutton has the stLinkCriteria = "[StatusID] = ?" changed. ? = 1 for
Active, 2 for Inactive, 3 for Deceased, etc.

Once the form is open I use a list box to go to specific records. The
problem is the list box is based on the original form and reads:

SELECT [qryCust].[Full name] FROM [qryCust];

How can I limit the list box to only display the records in the current
recordset of the form?

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top