Refresh or requery

O

operator

I am currently using Me.Requery as the function behind a "Refresh"
button. The behavior for Me.Requery is to run the RecordSource query on
the form and go to the first record of the subset. I would however like
it to stay (or go back) on the record being viewed before the Refresh
button was pushed.

Is there a way to store the offset of the record you are currently
viewing in a subset of records? I figure "DoCmd.GoToRecord , , ,
[Offset]" will work nicely for this approach. Or any other suggestions
for a workaround?

Thanks in advance.
 
J

Jeff Boyce

If you are requerying the entire form, why? What is it that you are
"refreshing"?

And another way to set up your form is so that it only points at one record,
rather than the full recordset. That way, a requery only returns that one
record (if it still qualifies to be seen).

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
O

operator

Thanks Jeff.

"If you are requerying the entire form, why? What is it that you are
"refreshing"? "

Great question actually. On second look, it serves no real function.
There used to be fields on subforms that would change fields on parent
forms and it took a requery for the end-user to see said changes. There
are AfterUpdate events now in place to take care of this functionality.

Regardless, the users I think would feel comfortable with a refresh
button available, whether or not it is superfluous. I can't have this
form point to just one record because the end-user likes to browse a
subset of records using the Access record selectors at the bottom left
of the form. Which brings me back to my question of is it possible to
store the offset of the record currently being viewed in a subset? This
way, in the "refresh" code I can have:

myInt = getCurrentOffset
Me.Requery
DoCmd.GoToRecord , , , myInt

Thanks again for the reply.
 
J

Jeff Boyce

Rather than an "offset", could you capture the recordID and use that to
navigate to the correct record?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top