Refresh Query Issue

reaktorblue

Board Regular
Joined
Aug 8, 2007
Messages
87
Office Version
  1. 365
Platform
  1. Windows
I have the below code on frmDashboard. When I click on cmdAddEmployee, I'm directed to frmAddEmployee and when finished and close, frmDashboard updates the list of Employees and goes to the latest record.

The below code works however, I've noticed an issue that when exiting out of this database, msaccess.exe is still running. I have to consistently end that task and then I can reopen the database successfully.

I've commented the below code out and then did not experience the issue above with msaccess.exe still running. Is there something wrong with my code below?

Code:
Private Sub Form_Activate()
'Refresh Employees displayed on Dashboard form by Last Record

    Dim rs As Recordset

    If DCount("*", "qryDashboardEmployees", [ID]) > 0 Then
        DoCmd.Requery
        Set rs = Me.RecordsetClone
        rs.FindFirst "id=dmax('ID', 'tblEmployees')"
        Me.Bookmark = rs.Bookmark
    End If
End Sub
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Likely this is firing since commenting it out has eliminated the problem (we think). I say likely because there are no other clues as to how the exit process happens, only that frmAddEmployee closes, which does not fire this event. The form has to get the focus for this to fire, so that may not be happening until you click a form command button to exit? I would add msgbox "Query all done" before End If and msgbox "Query didn't run" so you can see exactly when this fires and whether or not the query runs. You may be attempting to exit while this sub is running, although I'd have thought you'd get a system prompt of some sort.
A better way for what you're doing might be to set your dashboard form bookmark as the last operation in your frmAddEmployee, or set the focus to a control on this form as the last operation (easier) and the event should fire with Forms!frmFormNameHere.ControlNameHere.SetFocus.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,554
Messages
6,114,280
Members
448,562
Latest member
Flashbond

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