Runtime Error 3420 on Requery

Kemidan2014

Board Regular
Joined
Apr 4, 2022
Messages
226
Office Version
  1. 365
Platform
  1. Windows
I have a simple seperate access database that was set up to be a updating status board where it displays open issues.

its just 2 queries and 2 reports tied to linked table.

some time in the middle of the night (because we are a plant that runs 24/7) a runtime error 3420 pops up.

the code is VERY simple in the Timer event of the individual reports i have Reports![reportname].requery

and thats it. timer is set for 30 seconds. so that every 30 seconds the reports will update with latest records that the queries will pull up. we originally thought since the PC that runs this was on Wifi we were losing connection breifly in middle of the night so i had it switched to wired connection and it still gets the error.

is there some additional vba i could add to mitigate this error and essentially restart it?
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Might be helpful if you posted the code and identified the line raising the error?
 
Upvote 0
VBA Code:
Option Compare Database

Private Sub Report_Timer()
Reports![Open Issues].Requery

End Sub

Requery is highlighted when hitting Debug.
 
Upvote 0
So after some looking into this Error I believe it is related to that the recordsource is being updated or changed at the same moment that the requery is happening. So if this is the case is there any VBA code that could enter to confirm if the recordsource is dirty before the requery happens? and since this is a report that is being requeried and report is based off a query is that even possible?

I tried to replace the requery target to the query that the report is based off of but it produced a a fault that said it needed to be an ADP item
 
Upvote 0
If you change the recordsource, then a requery is not required.
 
Upvote 0
the recordsource is being updated or changed
This means what - someone is updating records? I don't think you meant that the recordsource is being changed. If I'm correct in those assumptions and a record is locked due to editing you don't want to force a save. Better to use an error handler and exit the sub and let the timer do it's thing when the lock is removed. TBH I didn't look up the error message for that number - getting tired of doing that when it's not part of the post.
 
Upvote 0
Yesterday i updated the VBA in Timer property to below. it still yeilded the same 3420 runtime fault "object is invalid" sometime in the middle of the night.

VBA Code:
Option Compare Database

Private Sub Report_Timer()
Reports![Open Issues].Requery

On Error Resume Next
 Exit Sub

End Sub

The records get updated or added constantly through out the day. is there additional coding i should have in this help mitigate the error when it occurs? is there a line of code that can check to see if there is record being locked for editting as you pointed out before it performs the requery that way i can basically set it up "do nothing if locked for editing, otherwise requery"
 
Upvote 0
You put the error handling first, not last.

VBA Code:
Private Sub Report_Timer()
On Error Resume Next

Reports![Open Issues].Requery
End Sub
As long as you don't care what the error is, that should solve the immediate issue. Yes you can check to see if something can be edited, but now that I know what your error message is I think the problem lies somewhere else. You probably close the report in some other code? You can't requery it if it's closed. Or is this code not requerying some other report but instead is requerying itself?
 
Upvote 0

Forum statistics

Threads
1,215,103
Messages
6,123,103
Members
449,096
Latest member
provoking

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top