Refresh continuous form after dialog window (1 Viewer)

smally

Registered User.
Local time
Today, 21:03
Joined
Mar 29, 2005
Messages
71
I have created a Continuous form and locked all the fields from editing. Each row has a button, the button opens another form in a dialog window so the data can be edited.

The issue I'm having is when the user updates the data in the dialog form, the continuous form does not update.
I have tried refresh, but it doesn't do anything. I tried requery, but this causes the continueous form view to jump to the top.
So I tried selecting the record afterwards, but this still makes the view change.

Below is what I currently have, is there a better way so when the dialog window closes, the continuous form updates with any changes AND the user's view stays where it is.

Code:
Private Sub cmdEditRecord_Click()

    Dim current As Integer
    current = Me.CurrentRecord

    DoCmd.OpenForm "frmAssessment", , , "AssessmentId = " & Me.ID, , acDialog
    Me.Requery
    DoCmd.GoToRecord , , acGoTo, current
    
End Sub
 

June7

AWF VIP
Local time
Today, 13:03
Joined
Mar 9, 2014
Messages
5,423
Code works for me. Cannot replicate issue.
 

smally

Registered User.
Local time
Today, 21:03
Joined
Mar 29, 2005
Messages
71
I've discover that the continuous form did not refresh because it was linked to a query which used COUNT and GROUP BY.
If the query does not have this, the continuous form would refresh as expected.
 

June7

AWF VIP
Local time
Today, 13:03
Joined
Mar 9, 2014
Messages
5,423
Why use a form for aggregate data? Why not a report?
 

smally

Registered User.
Local time
Today, 21:03
Joined
Mar 29, 2005
Messages
71
It never occurred to me to use a report.
It doesn't matter anyway. Using a report, even without the aggregate data the info doesn't update after the changes are made in the dialog popup window
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 21:03
Joined
Sep 12, 2006
Messages
15,614
I would have thought me.requery would still have worked.

me.refresh may not, but me.requery should. They are subtly different commands
 

MarkK

bit cruncher
Local time
Today, 14:03
Joined
Mar 17, 2004
Messages
8,178
I would do it like this...
Code:
Private Sub cmdEditRecord_Click()
    Dim current As Single
    current = Me.Recordset.PercentPosition

    DoCmd.OpenForm "frmAssessment", , , "AssessmentId = " & Me.ID, , acDialog
    Me.Requery
    Me.Recordset.PercentPosition = Current
End Sub
It's not clear what you do in the popup, but if you delete records the old Me.CurrentRecord position may not exist anymore.
fwiw,
Mark
 

Users who are viewing this thread

Top Bottom