Link to home
Start Free TrialLog in
Avatar of mlcktmguy
mlcktmguyFlag for United States of America

asked on

Refreshing Data On A continuous Screen, without using ‘Requery’

I developed a continuous screen ‘frmContinuous’ for a client.  The screen usually contains over a 100 records in the data set being worked on by the users.  Many more than can fit on the visible screen.  So the users have to scroll to get to many of the entries.

The recordsource of ’frmContinuous’ is a query combining data from multiple tables and other queries.

Each line on the continuous form has an ‘Edit’ button to the far left.  When the users clicks the ‘Edit’ button they are taken to another screen, ‘frmEdit’ that allows to revise some of the information shown on the continuous form.

When the users exit ‘frmEdit’ and return to ‘frmContinouos’ they want to be positioned on the record they were edting and have the information on ‘frmContinuous’ reflect changes (if any) that had been made in ‘frmEdit’

I don’t seem to be able to accomplish both.
If I don’t execute the ‘refresh’ when they return to frmContinuous, they are positioned exactly where the information on the screen for that record does not reflect any changes they made.

If I execute  a ‘Me.Requery’ when I return to frmContinuous’ the updated information is shown on the screen.  However, it also repositions the cursor to the first record on the screen.  This is particularly time consuming for them because they may have to scroll thru many records to get back to the record they want to work on next.

Is there any way to accomplish both objectives when returning to the continuous for?
1.       Maintain the position in the recordset
2.      Update the information shown on the screen for that record.
ASKER CERTIFIED SOLUTION
Avatar of Phillip Burton
Phillip Burton

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bitsqueezer
Hi,

you can use "Me.Refresh" instead if you only want to reflect changes to a record, that will not change the position of the record. But if you delete or insert a record you can only use Requery to get the changes.

I developed a "Reposition" method which is able to work with all kind of changes and returns to the edited record and also at the same position on the screen. You can find that here:

Reposition - requery with positioning to the recent record

Cheers,

Christian
Avatar of mlcktmguy

ASKER

Thanks for the responses:

More Info:
No records can be deleted or added on the continuous form or the 'edit' form.

First response
I would like to try this but I'm not familiar with the 'GoToRecord' command.

Could you be more specific as to the coding to implement your suggestion.

This is the code in my 'Edit' click event.

Private Sub btnEdit_Click()
 DoCmd.OpenForm "frmClientDistribution_New", , , , acFormEdit, acDialog, Me.ClientRecID
'Me.Refresh
Me.Requery
End Sub

I'm guessing prior to the 'Docmd.openform... I would have to store something that will take me directly to my record after I return from the form.

Then after the refresh I would use the GotToRecord but I'm not clear on the specifics

Something like:

Private Sub btnEdit_Click()

dim recordpointer as long

recordpointer = ???????
 DoCmd.OpenForm "frmClientDistribution_New", , , , acFormEdit, acDialog, Me.ClientRecID
'Me.Refresh
Me.Requery

docmd.gotorecord ????? recordpointer

End Sub

I tried using 'refresh' instead of 'requery' to stay on the same record but the information on the records was not updated.  It is only updated when I do the 'requery'.
Here is what I ended up with in my 'Edit' button routine

Private Sub btnEdit_Click()
'
Dim whichRecord As Long
whichRecord = Me.CurrentRecord
'
DoCmd.OpenForm "frmClientDistribution_New", , , , acFormEdit, acDialog, Me.ClientRecID
'
Me.Requery
'
DoCmd.GoToRecord acDataForm, "frmProjectedTransportation_Pre", acGoTo, whichRecord
'
End Sub