I have been asked to create a list of sample data for auditing on a weekly basis.
Random 5 Roads per district per week... Fine and done.
Pulled from tbl_Insp based on input date criteria input on a form and a "Select Top 5" query run in individual make table and append tables to give me a resultant tbl_Audits_stp1 table.
With a number of assets on those roads to be dependant on what has been attended with some pretty annoying calculations
I have therefore pulled this into another table with a numeric field of "ActualAttended" (pulled from the tbl_Insp) and a numeric field of "AuditQuant" based on calculation of count (each record in tbl_insp refers to an individual asset).
This is step is actually 2 queries as the number of iif statements in query expression is so large I have to do 2 and then do a final combination of the 2 make tables into a final
tbl_Audits_stp2.
So what I get is:
Roadname District ActualAttended AuditQuant
Liam Lane West 8 5
Francis Corner West 20 5.1
Margery Close West 200 20
Fransisco Drive West 10 5
Bartholomew Ave West 1 1
Trident Way South 7 5
Comet Close South 1020 102
Furbies Rock South 25 12.5
Flibble Fore South 33 11.33
Flintstone Road South 22 10
What I need to do now is get a Select Top query to accept a variable from a table but understand that can't be done in normal query design sql.
Instead have to some how create a means of calling the process in a form function and somehow opening the table
and looping through the enteries and somehow selecting the number of asset to be audited(again randomly from all those attended in the tbl_Insp)and input that in to a table.
Obviously the RoadName and District need to match (Can be same roadnames in other district)and the attended gullies need to be between the same date criteria as used for the same pull of "road samples" and total attended counts.
Another issue the above table example demonstrates is that of decimal places in the AuditQuant field. This must always be rounded UP so that, for example, Flibble Fore should have 12 assets selected from attended for audit.
Any assistance would be greatly appreciated, maybe I can get this done before the Xmas hols that I can enjoy them =)
Random 5 Roads per district per week... Fine and done.
Pulled from tbl_Insp based on input date criteria input on a form and a "Select Top 5" query run in individual make table and append tables to give me a resultant tbl_Audits_stp1 table.
With a number of assets on those roads to be dependant on what has been attended with some pretty annoying calculations
I have therefore pulled this into another table with a numeric field of "ActualAttended" (pulled from the tbl_Insp) and a numeric field of "AuditQuant" based on calculation of count (each record in tbl_insp refers to an individual asset).
This is step is actually 2 queries as the number of iif statements in query expression is so large I have to do 2 and then do a final combination of the 2 make tables into a final
tbl_Audits_stp2.
So what I get is:
Roadname District ActualAttended AuditQuant
Liam Lane West 8 5
Francis Corner West 20 5.1
Margery Close West 200 20
Fransisco Drive West 10 5
Bartholomew Ave West 1 1
Trident Way South 7 5
Comet Close South 1020 102
Furbies Rock South 25 12.5
Flibble Fore South 33 11.33
Flintstone Road South 22 10
What I need to do now is get a Select Top query to accept a variable from a table but understand that can't be done in normal query design sql.
Instead have to some how create a means of calling the process in a form function and somehow opening the table
and looping through the enteries and somehow selecting the number of asset to be audited(again randomly from all those attended in the tbl_Insp)and input that in to a table.
Obviously the RoadName and District need to match (Can be same roadnames in other district)and the attended gullies need to be between the same date criteria as used for the same pull of "road samples" and total attended counts.
Another issue the above table example demonstrates is that of decimal places in the AuditQuant field. This must always be rounded UP so that, for example, Flibble Fore should have 12 assets selected from attended for audit.
Any assistance would be greatly appreciated, maybe I can get this done before the Xmas hols that I can enjoy them =)