Solved

previously null

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now