Refresh Query Issue

reaktorblue

Board Regular
Joined
Aug 8, 2007
Messages
76
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
 

Some videos you may like

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Micron

Well-known Member
Joined
Jun 3, 2015
Messages
1,845
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:

Watch MrExcel Video

Forum statistics

Threads
1,101,756
Messages
5,482,698
Members
407,358
Latest member
Maze123

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top