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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update one List Box row source from value selected in other list box 1

Status
Not open for further replies.

THWatson

Technical User
Apr 25, 2000
2,601
CA
Using Access 2007

This should be relatively easy but, for whatever reason, I am having trouble getting things to work properly.

On a form there are 2 list boxes.

The first list box, called lstYearLastVisit, has the following row source
Code:
SELECT qryPatients.YearLastVisit
FROM qryPatients
GROUP BY qryPatients.YearLastVisit;

The second, called lstPatients, has the following row source
Code:
SELECT tblPatients.PatientID, [PatLast] & ": " & [PatFirst]+(" " & [PatMiddle]) AS FullName, tblPatients.PatFirst, tblPatients.PatMiddle, tblPatients.PatLast, tblPatients.DateBirth, tblPatients.DateLastVisit, Year([DateLastVisit]) AS YearLastVisit
FROM tblPatients;

I want to be able to change the row source in lstPatients, to reflect the Year selected in lstYearLastVisit.

Tom


 
You can either use code to change the Row Source property of the second or you can add a criteria to the second list box.
Code:
CODE
SELECT tblPatients.PatientID, [PatLast] & ": " & [PatFirst]+(" " & [PatMiddle]) AS FullName, tblPatients.PatFirst, tblPatients.PatMiddle, tblPatients.PatLast, tblPatients.DateBirth, tblPatients.DateLastVisit, Year([DateLastVisit]) AS YearLastVisit
FROM tblPatients
WHERE Year([DateLastVisit]) = Forms!NoFormNameGiven!lstYearLastVisit;
You may need code to requery the second list box after the update of the first.

Duane
Hook'D on Access
MS Access MVP
 
Duane
Thanks. That works.

I had been tinkering with that but used Me instead of spelling out the full Forms!frmName!lstYearLastVisit.

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top