Re: Requery Not Working

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



That closed the main menu too. I wanted the main menu to stay open,
but have a field on it update.
On Apr 16, 11:24 am, Klatuu <Kla...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
The Requery is working.  You have your order of actions upside down.  You
need to save the record before you requery the form.  The refresh is
unnecessary.  Try this version:

    On Error GoTo Err_CloseImportForm_Click

    If Me.Dirty Then
        Me.Dirty = False
        If CurrentProject.AllForms("Frm_Main_Menu").IsLoaded Then
            Forms![Frm_Main_Menu].Requery
        End If
    End If

    DoCmd.Close acForm, Me.Name, acSaveNo

This will only requery the form If the record was added to the table.

--
Dave Hargis, Microsoft Access MVP



"sandpk...@xxxxxxxxx" wrote:
From the main menu, I have a Max query that displays the most recent
date of a particular field.  When I go into a form off of the main
menu and update that field, I'd like the main menu to be updated.  The
code below does not work.  Any help is appreciated.
Private Sub Command15_Click()
Dim frm As Form

On Error GoTo Err_CloseImportForm_Click

If CurrentProject.AllForms("Frm_Main_Menu").IsLoaded Then
    Set frm = Forms![Frm_Main_Menu]
    frm.Requery
    frm.Refresh
    Set frm = Nothing
End If
If Me.Dirty Then Me.Dirty = False

DoCmd.Close

Exit_CloseImportForm_Click:
    Exit Sub

Err_CloseImportForm_Click:
    MsgBox Err.Description
    Resume Exit_CloseImportForm_Click

End Sub- Hide quoted text -

- Show quoted text -

.



Relevant Pages

  • Re: Cant cancel an automatic Access message
    ... I provide an appropriate error message and cancel the closing ... Private Sub Form_Unload ... DoCmd.Close along with the error handling code and your own ...
    (microsoft.public.access.formscoding)
  • Re: Trigger event to set values in controls and disable them
    ... this table are Review ID, CompID, Score and Comment. ... DoCmd.GoToRecord = acNext ... Private Sub YourCombo_AfterUpdate ...   Else   ...
    (microsoft.public.access.forms)
  • Re: Cant cancel an automatic Access message
    ... I provide an appropriate error message and cancel the closing ... Private Sub Form_Unload ... I also think there might be something wrong with the error trapping ...
    (microsoft.public.access.formscoding)
  • Re: Can VB determine location of last cell changed?
    ... Public InModule As Boolean ... Private Sub Worksheet_Change ...     If Not InModule Then ... Here I have assumed your macro is named YourMacro ...
    (microsoft.public.excel.programming)
  • Re: Select name from drop down and return associated value
    ... Private Sub Worksheet_Change ...    Are you saying that you want the user to select from a dropdown some ... but you want Excel to display the course code in that same ... corresponding course codes are in Column B of the same sheet. ...
    (microsoft.public.excel)