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

Records missing from listbox but present in underlying query??? 1

Status
Not open for further replies.

leicklda

Technical User
Mar 18, 2002
46
US
Very strange problem...
I noticed that one of my listboxes is missing some records, and so I checked its underlying query (which is assigned through the listbox.rowsource VB property) to find the problem. The strange thing is that the missing records ARE present in the underlying query results!

I've flipped views back and forth thinking I must be missing something, but it's clear as day - when I look at the listbox, there are 3 records (2 records missing). When I open the SQL statement directly behind the listbox by pressing the 3 dots next to the rowsource field in the property sheet and running that query, all 5 records are there.

The listbox has multiple "OR" conditions defined in the criteria. It is always the same 2 categories of the criteria that are missing. Here is the SQL (dynamically assigned) behind the listbox:

SELECT tblPlanRevisions.RevisionID, IIf([revlevel]=1,'M.Pln',IIf([revlevel]=2,'Div',IIf([revlevel]=3,'Comm',IIf([revlevel]=4,'C.Pln','Corp')))) AS Scope, Format([revdate],'mm/dd/yy') AS [Rev Date], tblPlanRevisions.Description
FROM tblPlanRevisions
WHERE (((tblPlanRevisions.RevLevel)=4) AND ((tblPlanRevisions.fkCommunityPlanID)=43)) OR (((tblPlanRevisions.RevLevel)=3) AND ((tblPlanRevisions.fkCommunityID)=1)) OR (((tblPlanRevisions.RevLevel)=2) AND ((tblPlanRevisions.fkDivisionID)=205)) OR (((tblPlanRevisions.RevLevel)=1) AND ((tblPlanRevisions.fkMasterPlanID)="2051")) OR (((tblPlanRevisions.RevLevel)=5));


I know this looks hairy, but I'm sure its not a syntax error b/c when running this as a query, it works fine. It is only in the listbox that certain records are missing. The categories that are missing are the ones from the criteria of 'fkMasterplanid and 2015', and 'revlevel=5'.

Any ideas????
 
make this into a query and assign the name of the query to the listbox.

Brought to you By Nedaineum
 
Thanks - that worked. Now I need to go and change my VB code which constantly updated that SQL as a series of variables to instead change a querydef.

Strange problem, but your solution worked great. Thanks!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top