Disabling a Command Button for 15 seconds.
Hi, I am learning Access/SQL and started building forms as a front end. I have a command button that runs the following code.
DoCmd.SetWarnings False
DoCmd.OpenQuery "qrAllocationsPhase1Update"
DoCmd.OpenQuery "qrtemptable"
DoCmd.OpenQuery "qrBeginingbalance"
DoCmd.OpenQuery "qrNextBreakUpdateTrue"
DoCmd.OpenQuery "qrTaxProvisionUpdate"
DoCmd.OpenQuery "qrRevalTaxUpdate"
DoCmd.OpenQuery "qrRevalTaxPhase2Update"
DoCmd.OpenQuery "qrTaxStuffingGainsUpdate"
DoCmd.OpenQuery "qrTaxStuffingLossesUpdate"
DoCmd.OpenQuery "qrTemporaryTaxAllocationsEco"
DoCmd.OpenQuery "qrTemporaryTaxAllocationsPR"
DoCmd.OpenQuery "qrTemporaryTaxAllocationsNR"
DoCmd.OpenQuery "qrTemporaryTaxAllocations2Eco"
DoCmd.OpenQuery "qrTemporaryTaxAllocations2PR"
DoCmd.OpenQuery "qrTemporaryTaxAllocations2NR"
DoCmd.OpenQuery "qrTaxAllocationEcoUpdate"
DoCmd.OpenQuery "qrTaxAllocationNRUpdate"
DoCmd.OpenQuery "qrTaxAllocationPRUpdate"
DoCmd.OpenQuery "qrTemporaryTaxAllocationsEcoDelete"
DoCmd.OpenQuery "qrTemporaryTaxAllocationsPRDelete"
DoCmd.OpenQuery "qrTemporaryTaxAllocationsNRDelete"
DoCmd.OpenQuery "qrTemporaryTaxAllocations2EcoDelete"
DoCmd.OpenQuery "qrTemporaryTaxAllocations2PRDelete"
DoCmd.OpenQuery "qrTemporaryTaxAllocations2NRDelete"
DoCmd.OpenQuery "qrAllocationPhase1Delete"
DoCmd.OpenQuery "qrTaxBasisUpdate"
DoCmd.SetWarnings True
Me![fmBreakDateOpenClose]![Allocated] = True
It takes about 10-15 seconds to run the code and have found that if the user pushes the button a second time, before the first cycle is done it ruins all the data because it starts doubling up. Is there a way to disable the command button for 15 seconds so this does not happen? I have searched the boards and found something called Twait, shown below, but I have no idea how to apply it or if it is even the correct way to go. If you look at my code and laugh that's fine just help me I need it.
TWait = Time
TWait = DateAdd("s", 15, TWait)
Do Until TNow >= TWait
TNow = Time
Loop
Hi, I am learning Access/SQL and started building forms as a front end. I have a command button that runs the following code.
DoCmd.SetWarnings False
DoCmd.OpenQuery "qrAllocationsPhase1Update"
DoCmd.OpenQuery "qrtemptable"
DoCmd.OpenQuery "qrBeginingbalance"
DoCmd.OpenQuery "qrNextBreakUpdateTrue"
DoCmd.OpenQuery "qrTaxProvisionUpdate"
DoCmd.OpenQuery "qrRevalTaxUpdate"
DoCmd.OpenQuery "qrRevalTaxPhase2Update"
DoCmd.OpenQuery "qrTaxStuffingGainsUpdate"
DoCmd.OpenQuery "qrTaxStuffingLossesUpdate"
DoCmd.OpenQuery "qrTemporaryTaxAllocationsEco"
DoCmd.OpenQuery "qrTemporaryTaxAllocationsPR"
DoCmd.OpenQuery "qrTemporaryTaxAllocationsNR"
DoCmd.OpenQuery "qrTemporaryTaxAllocations2Eco"
DoCmd.OpenQuery "qrTemporaryTaxAllocations2PR"
DoCmd.OpenQuery "qrTemporaryTaxAllocations2NR"
DoCmd.OpenQuery "qrTaxAllocationEcoUpdate"
DoCmd.OpenQuery "qrTaxAllocationNRUpdate"
DoCmd.OpenQuery "qrTaxAllocationPRUpdate"
DoCmd.OpenQuery "qrTemporaryTaxAllocationsEcoDelete"
DoCmd.OpenQuery "qrTemporaryTaxAllocationsPRDelete"
DoCmd.OpenQuery "qrTemporaryTaxAllocationsNRDelete"
DoCmd.OpenQuery "qrTemporaryTaxAllocations2EcoDelete"
DoCmd.OpenQuery "qrTemporaryTaxAllocations2PRDelete"
DoCmd.OpenQuery "qrTemporaryTaxAllocations2NRDelete"
DoCmd.OpenQuery "qrAllocationPhase1Delete"
DoCmd.OpenQuery "qrTaxBasisUpdate"
DoCmd.SetWarnings True
Me![fmBreakDateOpenClose]![Allocated] = True
It takes about 10-15 seconds to run the code and have found that if the user pushes the button a second time, before the first cycle is done it ruins all the data because it starts doubling up. Is there a way to disable the command button for 15 seconds so this does not happen? I have searched the boards and found something called Twait, shown below, but I have no idea how to apply it or if it is even the correct way to go. If you look at my code and laugh that's fine just help me I need it.
TWait = Time
TWait = DateAdd("s", 15, TWait)
Do Until TNow >= TWait
TNow = Time
Loop