Solved

previously null

Posted on 2011-03-13
5
198 Views
Last Modified: 2012-05-11
I have an access query that is looking at two tables one current data and the other last months data and the query is picking up where there is a difference.

It is not picking up where it was null previously null with the current value populated ie data came in for that particular field.

How can I pick up that scenario too?

not sure if i also want the reverse ie i no longer have data but had it last month ie the current field became null.

am working in access query grid
regards in advance

SELECT SMMT.[MVRIS CODE], IIf(Trim([SMMT].[INTRO DATE])<>Trim([SMMT_Previous].[INTRO DATE]),1,0) AS Introdiff, IIf(Trim([SMMT].[marque])<>Trim([SMMT_Previous].[marque]),1,0) AS MarqueDiff, IIf(Trim([SMMT].[model range])<>Trim([SMMT_Previous].[model range]),1,0) AS ModelRangeDiff, IIf(Trim([SMMT].[Range series])<>Trim([SMMT_Previous].[Range series]),1,0) AS RangeSeriesDiff, IIf(Trim([SMMT].[variant])<>Trim([SMMT_Previous].[variant]),1,0) AS VariantDiffA, IIf(Trim([SMMT].[cc])<>Trim([SMMT_Previous].[cc]),1,0) AS CCDiff, IIf(Trim([SMMT].[nom cc])<>Trim([SMMT_Previous].[nom cc]),1,0) AS NomCCDiff, IIf(Trim([SMMT].[doors])<>Trim([SMMT_Previous].[doors]),1,0) AS DoorsDiff, IIf(Trim([SMMT].[Body Type])<>Trim([SMMT_Previous].[Body type]),1,0) AS BodyTypeDiff, IIf(Trim([SMMT].[Transmission])<>Trim([SMMT_Previous].[Transmission]),1,0) AS TransmissionDiff, IIf(Trim([SMMT].[fuel])<>Trim([SMMT_Previous].[fuel]),1,0) AS FuelDiff, IIf(Trim([SMMT].[aspiration])<>Trim([SMMT_Previous].[aspiration]),1,0) AS AspirationDiff, IIf(Trim([SMMT].[drive type])<>Trim([SMMT_Previous].[drive type]),1,0) AS DriveTypeDiff, IIf(Trim([SMMT].[driving axle])<>Trim([SMMT_Previous].[driving axle]),1,0) AS DrivingAxleDiff, IIf(Trim([SMMT].[forward gears])<>Trim([SMMT_Previous].[forward gears]),1,0) AS ForwardGearsDiff, IIf(Trim([SMMT].[seats])<>Trim([SMMT_Previous].[seats]),1,0) AS SeatsDiff, IIf(Trim([SMMT].[engine model])<>Trim([SMMT_Previous].[engine model]),1,0) AS EngineModelDiff, IIf(Trim([SMMT].[fuel delivery])<>Trim([SMMT_Previous].[fuel delivery]),1,0) AS FuelDelDiff, IIf(Trim([SMMT].[no cylinders])<>Trim([SMMT_Previous].[no cylinders]),1,0) AS NoCylDiff, IIf(Trim([SMMT].[valves per cylinder])<>Trim([SMMT_Previous].[valves per cylinder]),1,0) AS ValvespercylDiff, IIf(Trim([SMMT].[valve gear])<>Trim([SMMT_Previous].[valve gear]),1,0) AS valvegearDiff, IIf(Trim([SMMT].[power kw])<>Trim([SMMT_Previous].[power kw]),1,0) AS powerkwDiff, IIf(Trim([SMMT].[calc bhp])<>Trim([SMMT_Previous].[calc bhp]),1,0) AS calcbhpDiff, IIf(Trim([SMMT].[co2])<>Trim([SMMT_Previous].[co2]),1,0) AS co2Diff, IIf(Trim([SMMT].[gvw])<>Trim([SMMT_Previous].[gvw]),1,0) AS gvwDiff, IIf(Trim([SMMT].[cab type])<>Trim([SMMT_Previous].[cab type]),1,0) AS cabDiff, IIf(Trim([SMMT].[van roof config])<>Trim([SMMT_Previous].[van roof config]),1,0) AS vanroofDiff, IIf(Trim([SMMT].[wheelbase type])<>Trim([SMMT_Previous].[wheelbase type]),1,0) AS wheelbasetypeDiff
FROM SMMT INNER JOIN SMMT_Previous ON SMMT.[MVRIS CODE] = SMMT_Previous.[MVRIS CODE]
WHERE (((IIf(Trim([SMMT].[INTRO DATE])<>Trim([SMMT_Previous].[INTRO DATE]),1,0))>0)) OR (((IIf(Trim([SMMT].[marque])<>Trim([SMMT_Previous].[marque]),1,0))>0)) OR (((IIf(Trim([SMMT].[model range])<>Trim([SMMT_Previous].[model range]),1,0))>0)) OR (((IIf(Trim([SMMT].[Range series])<>Trim([SMMT_Previous].[Range series]),1,0))>0)) OR (((IIf(Trim([SMMT].[variant])<>Trim([SMMT_Previous].[variant]),1,0))>0)) OR (((IIf(Trim([SMMT].[cc])<>Trim([SMMT_Previous].[cc]),1,0))>0)) OR (((IIf(Trim([SMMT].[nom cc])<>Trim([SMMT_Previous].[nom cc]),1,0))>0)) OR (((IIf(Trim([SMMT].[doors])<>Trim([SMMT_Previous].[doors]),1,0))>0)) OR (((IIf(Trim([SMMT].[Body Type])<>Trim([SMMT_Previous].[Body type]),1,0))>0)) OR (((IIf(Trim([SMMT].[Transmission])<>Trim([SMMT_Previous].[Transmission]),1,0))>0)) OR (((IIf(Trim([SMMT].[fuel])<>Trim([SMMT_Previous].[fuel]),1,0))>0)) OR (((IIf(Trim([SMMT].[aspiration])<>Trim([SMMT_Previous].[aspiration]),1,0))>0)) OR (((IIf(Trim([SMMT].[drive type])<>Trim([SMMT_Previous].[drive type]),1,0))>0)) OR (((IIf(Trim([SMMT].[driving axle])<>Trim([SMMT_Previous].[driving axle]),1,0))>0)) OR (((IIf(Trim([SMMT].[forward gears])<>Trim([SMMT_Previous].[forward gears]),1,0))>0)) OR (((IIf(Trim([SMMT].[seats])<>Trim([SMMT_Previous].[seats]),1,0))>0)) OR (((IIf(Trim([SMMT].[engine model])<>Trim([SMMT_Previous].[engine model]),1,0))>0)) OR (((IIf(Trim([SMMT].[fuel delivery])<>Trim([SMMT_Previous].[fuel delivery]),1,0))>0)) OR (((IIf(Trim([SMMT].[no cylinders])<>Trim([SMMT_Previous].[no cylinders]),1,0))>0)) OR (((IIf(Trim([SMMT].[valves per cylinder])<>Trim([SMMT_Previous].[valves per cylinder]),1,0))>0)) OR (((IIf(Trim([SMMT].[valve gear])<>Trim([SMMT_Previous].[valve gear]),1,0))>0)) OR (((IIf(Trim([SMMT].[power kw])<>Trim([SMMT_Previous].[power kw]),1,0))>0)) OR (((IIf(Trim([SMMT].[calc bhp])<>Trim([SMMT_Previous].[calc bhp]),1,0))>0)) OR (((IIf(Trim([SMMT].[co2])<>Trim([SMMT_Previous].[co2]),1,0))>0)) OR (((IIf(Trim([SMMT].[gvw])<>Trim([SMMT_Previous].[gvw]),1,0))>0)) OR (((IIf(Trim([SMMT].[cab type])<>Trim([SMMT_Previous].[cab type]),1,0))>0)) OR (((IIf(Trim([SMMT].[van roof config])<>Trim([SMMT_Previous].[van roof config]),1,0))>0)) OR (((IIf(Trim([SMMT].[wheelbase type])<>Trim([SMMT_Previous].[wheelbase type]),1,0))>0))
ORDER BY SMMT.[MVRIS CODE];

Open in new window

0
Comment
Question by:PeterBaileyUk
  • 4
5 Comments
 
LVL 21

Accepted Solution

by:
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP earned 500 total points
ID: 35122415
Try using the Bz() fucntion

Example:

where IIf( Trim(Nz([SMMT].[INTRO DATE])) <> Trim(Nz([SMMT_Previous].[INTRO DATE])) ,1,0) >0  Or 

Open in new window


or simplified to

where IIf( Trim(Nz([SMMT].[INTRO DATE])) <> Trim(Nz([SMMT_Previous].[INTRO DATE])) ,True,False)  Or 

Open in new window


even more simplified:

where (Trim(Nz([SMMT].[INTRO DATE]) <> Trim(Nz([SMMT_Previous].[INTRO DATE]))) Or 

Open in new window


Why all the TRIM()'s?

Are the dates stored as text not data/time data type?



0
 

Author Comment

by:PeterBaileyUk
ID: 35122435
text unfortunately
0
 

Author Comment

by:PeterBaileyUk
ID: 35122448
wanted to get rid of possible left and or right spaces at the end of the strings
0
 

Author Comment

by:PeterBaileyUk
ID: 35122459
dont know this function Bz() ;)
0
 

Author Closing Comment

by:PeterBaileyUk
ID: 35122513
went for  (Trim(Nz([SMMT].[INTRO DATE]))<>Trim(Nz([SMMT_Previous].[INTRO DATE])))
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question