I apologize if this question already exists - I've tried looking for a solution and have not found one yet.
I have a database template that is used to set up individual databases to process client data that is not always in the same format or sometimes has additional fields. I am trying to build a query that will test the results of a cumulative table and ensure that the analyst who set up the new database did not miss anything. Ultimately I just need a way to show if there are any fields in the cumulative table that are NULL for every record and tell me the field names.
I've tried setting up a query using SWITCH and IIF but there are too many fields involved so invariably I get the Expression Too Complex error.
This is an example of the query, though my database will ultimately have 70 fields that need to be tested for null values after setup.
SELECT SWITCH(
TBL_Cumulative.[ScreeningDate] IS NULL, "ScreeningDate Missing",
TBL_Cumulative.[ScreeningLocation] IS NULL, "ScreeningLocation Missing",
TBL_Cumulative.[Source] IS NULL, "Source Missing",
TBL_Cumulative.[FirstName] IS NULL, "FirstName Missing",
TBL_Cumulative.[LastName] IS NULL, "LastName Missing",
TBL_Cumulative.[DOB] IS NULL, "DOB Missing",
TBL_Cumulative.[Female] IS NULL, "Female Missing",
TBL_Cumulative.[Male] IS NULL, "Male Missing",
TBL_Cumulative.[Height_FT] IS NULL, "Height_FT Missing",
TBL_Cumulative.[Height_IN] IS NULL, "Height_IN Missing",
TBL_Cumulative.[Weight] IS NULL, "Weight Missing",
TBL_Cumulative.[Fasting_Y] IS NULL, "Fasting_Y Missing",
TBL_Cumulative.[Fasting_N] IS NULL, "Fasting_N Missing",
TBL_Cumulative.[Pregnant_Y] IS NULL, "Pregnant_Y Missing",
TBL_Cumulative.[Pregnant_N] IS NULL, "Pregnant_N Missing",
TBL_Cumulative.[Tobacco_Y] IS NULL, "Tobacco_Y Missing",
TBL_Cumulative.[Tobacco_N] IS NULL, "Tobacco_N Missing",
TBL_Cumulative.[hbA1c] IS NULL, "hbA1c Missing",
TBL_Cumulative.[Cotinine] IS NULL, "Cotinine Missing",
TBL_Cumulative.[TSH] IS NULL, "TSH Missing",
TBL_Cumulative.[PSA] IS NULL, "PSA Missing") AS Error FROM TBL_Cumulative