Criteria in query

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Criteria in query

Post by D Willett »

Hi.
Can I use the following expression in a query criteria:

Not In ([forms]![frmEditVehicle]![jobD])

I'm trying to return records via a listbox where the current Registration exists in tblEst but not the current jobID on the form.

Code: Select all

SELECT tblEST.Registration, tblEST.Manufacturer, tblEST.Model, tblEST.VehBody, tblEST.VehSize, tblEST.VehYear, tblEST.[VIN-Chassis], tblEST.EngineNumber, tblEST.PaintType, tblEST.PaintCode, tblEST.VehColour, tblEST.JobID
FROM tblEST
WHERE (((tblEST.Registration)=[forms]![frmEditVehicle]![Registration]) AND ((tblEST.JobID) Not In ([forms]![frmEditVehicle]![jobD])));
Explanation.
When a user creates a Registration it is saved in tblEst, the next form to load is frmEditVehicle which has a listbox with the above SQL. I want to return any other record where the Registration matches but not the current JobID.
Cheers ...

Dave.

User avatar
HansV
Administrator
Posts: 78485
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Criteria in query

Post by HansV »

Try

...
WHERE (((tblEST.Registration)=[forms]![frmEditVehicle]![Registration]) AND ((tblEST.JobID) <> [forms]![frmEditVehicle]![jobD]));
Best wishes,
Hans

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Re: Criteria in query

Post by D Willett »

Got it.
WHERE (((tblEST.Registration)=[forms]![frmEditVehicle]![Registration]) AND ((tblEST.JobID) <> [forms]![frmEditVehicle]![jobD]));

There's an I missing in JobID........ ( my mistake )

:grin:
Cheers ...

Dave.