Solved

previously null

Posted on 2011-03-13
5
197 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

785 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