change to SQL - where and what?

  • Thread starter John B. Smotherman
  • Start date
J

John B. Smotherman

I tried posting this question before but got an error response from the
server. I apologize in advance if this try results in duplicate posts...

First some background (running Access2007 on XP Pro):
Our inventory database has a form (frmCheckOut) containing a subform
(sfmCheckOutList) for an employee to fill out when taking equipment to a
remote location. The subform is displayed in datasheet view, and is populated
via VBA code that transfers selections in a listbox on a popup form
(frmAddItems). The listbox is populated via SQL code in the RowSource
property of the control:

SELECT qryAddItems.ID_Number, qryAddItems.ItemName,
qryAddItems.ItemDescription, qryAddItems.Manufacturer,
qryAddItems.ModelNumber, qryAddItems.SerialNumber,
qryAddItems.CurrentLocation FROM qryAddItems ORDER BY [ID_Number];

This SQL code refers to a query rather than the main items table, for it
applies some selection criteria necessary to make sure the item is available
for checkout (not already checked out to someone else, not in the calibration
lab, small enough to transport, etc).

Now my questions:
1. Because the popup form may be opened and closed multiple time, with
transfers to the subform each time, I'd like to implement a further criteria:
not already listed in the subform.
2. Would it be best to place this criteria in the query qryAddItems, or in
the SQL for the RowSource of the listbox control?
3. What would the SQL for this look like? I've already tried the following
snippet as a criteria in the query:

....WHERE (((tblItems.ID_Number) Not In
([forms]![frmCheckOut]![sfmCheckOutList]![hrID])) AND...

which resulted in only the first item in the subform not being shown. I know
I'm close. What am I missing?

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