Hello, I have a question regarding some subtotal code I have on a form. This code calculates a subtotal for the status of each product returned for repair (taken from a backlog query, which show all products in house, and their status). The code is as follows:
Me.WarWIP.Caption = DCount("[Warranty Status]", "Backlog", "[Current Status]='WIP' and [Warranty Status]='Under Warranty'")
Me.WarAWM.Caption = DCount("[Warranty Status]", "Backlog", "[Current Status]='AWM' and [Warranty Status]='Under Warranty'")
Me.WarAWA.Caption = DCount("[Warranty Status]", "Backlog", "[Current Status]='AWA' and [Warranty Status]='Under Warranty'")
Me.WarPPW.Caption = DCount("[Warranty Status]", "Backlog", "[Current Status]='PPW' and [Warranty Status]='Under Warranty'")
Me.WarNAF.Caption = DCount("[Warranty Status]", "Backlog", "[Current Status]='NAF' and [Warranty Status]='Under Warranty'")
Me.NonWIP.Caption = DCount("[Warranty Status]", "Backlog", "[Current Status]='WIP' and [Warranty Status]='Out Of Warranty'")
Me.NonAWM.Caption = DCount("[Warranty Status]", "Backlog", "[Current Status]='AWM' and [Warranty Status]='Out Of Warranty'")
Me.NonAWA.Caption = DCount("[Warranty Status]", "Backlog", "[Current Status]='AWA' and [Warranty Status]='Out Of Warranty'")
Me.NonPPW.Caption = DCount("[Warranty Status]", "Backlog", "[Current Status]='PPW' and [Warranty Status]='Out Of Warranty'")
Me.NonNAF.Caption = DCount("[Warranty Status]", "Backlog", "[Current Status]='NAF' and [Warranty Status]='Out Of Warranty'")
This code works wonderfully, unfortunately however, it is very slow, taking nearly a minute to load. This code is run in the On Open event on my switchboard, so it is the first thing to load when the database is opened, and since it is so slow, it is very unattractive. Is there anyway I can streamline this code, so that it loads faster? Any help is greatly appreciated, and just let me know if you need more information, or anything I typed is unclear. Thanks!
Me.WarWIP.Caption = DCount("[Warranty Status]", "Backlog", "[Current Status]='WIP' and [Warranty Status]='Under Warranty'")
Me.WarAWM.Caption = DCount("[Warranty Status]", "Backlog", "[Current Status]='AWM' and [Warranty Status]='Under Warranty'")
Me.WarAWA.Caption = DCount("[Warranty Status]", "Backlog", "[Current Status]='AWA' and [Warranty Status]='Under Warranty'")
Me.WarPPW.Caption = DCount("[Warranty Status]", "Backlog", "[Current Status]='PPW' and [Warranty Status]='Under Warranty'")
Me.WarNAF.Caption = DCount("[Warranty Status]", "Backlog", "[Current Status]='NAF' and [Warranty Status]='Under Warranty'")
Me.NonWIP.Caption = DCount("[Warranty Status]", "Backlog", "[Current Status]='WIP' and [Warranty Status]='Out Of Warranty'")
Me.NonAWM.Caption = DCount("[Warranty Status]", "Backlog", "[Current Status]='AWM' and [Warranty Status]='Out Of Warranty'")
Me.NonAWA.Caption = DCount("[Warranty Status]", "Backlog", "[Current Status]='AWA' and [Warranty Status]='Out Of Warranty'")
Me.NonPPW.Caption = DCount("[Warranty Status]", "Backlog", "[Current Status]='PPW' and [Warranty Status]='Out Of Warranty'")
Me.NonNAF.Caption = DCount("[Warranty Status]", "Backlog", "[Current Status]='NAF' and [Warranty Status]='Out Of Warranty'")
This code works wonderfully, unfortunately however, it is very slow, taking nearly a minute to load. This code is run in the On Open event on my switchboard, so it is the first thing to load when the database is opened, and since it is so slow, it is very unattractive. Is there anyway I can streamline this code, so that it loads faster? Any help is greatly appreciated, and just let me know if you need more information, or anything I typed is unclear. Thanks!