Solved

previously null

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Export Query data to excel file 14 38
Query design issue 2 24
MS Access VBA Print PDF just Current Page 9 12
Access 2003, sort table via code 5 8
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

864 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

25 Experts available now in Live!

Get 1:1 Help Now