lock table

Okay, so see - that was very good. It allowed me to spot the problem right away. There are a couple of problems:

1. This form that you have the code on is bound to the table.

2. You are using a timer to run the queries but a few things about that:
a. You have the timer interval set to 600 (which is 600 milliseconds) and you
b. Never turn off the timer - so every 600 milliseconds this code is continuing to fire.

3. You can't close the form in the code because the code is on the form you are telling it to close. It can't close itself until all code has been run.

I think you need to have the form code open the frmReload and then close itself and put the code to run the queries on the frmReload and then have it reopen the other form and then close itself.

For the reload form you can set the status between queries but you also need to include this in between each:

' code for query here then
Me.Repaint
DoEvents
' code for next query here then
Me.Repaint
DoEvents


that way you can have it update in between each query to really show the status.

Glad that helped :)

Yeah, the timer is set so low just for testing, rather than wait every 15 minutes or so, which is how it will eventually be.

That makes sense about the code, so I will move it partly to the other form and see if that works.

If it does, I owe you a pint :) Probably a virtual one.

Will send you a message tomorrow with the outcome.

Thanks again for all your help
 
Result!

The form TblTotalPorts now looks like this:
Code:
Private Sub Form_Timer()
DoCmd.SetWarnings False
DoCmd.OpenForm "frmReload"
Me.Repaint
DoEvents
'DoCmd.Close acForm, "TblTotalPorts", acSaveNo
'Me.Repaint
'DoEvents
End Sub

and the frmReload looks like this:

Code:
Private Sub Form_Timer()
DoCmd.Close acForm, "TblTotalPorts", acSaveNo
Me.Repaint
DoEvents
DoCmd.OpenQuery "QDeleteDump", acNormal, acEdit
DoCmd.OpenQuery "QMakeDump", acNormal, acEdit
Me.Repaint
DoEvents
DoCmd.OpenQuery "QDeletePorts", acNormal, acEdit
DoCmd.OpenQuery "QPorts", acNormal, acEdit
Me.Repaint
DoEvents
DoCmd.OpenQuery "QDeleteTotalPorts", acNormal, acEdit
DoCmd.OpenQuery "QPortCount", acNormal, acEdit
Me.Repaint
DoEvents
DoCmd.OpenForm "TblTotalPorts"
'DoCmd.Close acForm, "frmReload", acSaveNo
'Me.Repaint
'DoEvents

it works!!

Thanks so much for all your help :D
 
Whew! Glad that's sorted.
 

Users who are viewing this thread

Back
Top Bottom