Requery, Refresh is there better way to do it then I have been

B

BrianPaul

I have a form with a listbox. I have an event on double click on the listbox
that opens a form that coresponds to the value in the listbox to edit. After
I edit the record I have a command button to close the popup form. however
to Requerry the list box I have to re-open the form (keep in mind the form is
already opened in the background) then use the statement to requery the
listbox.

I have tried everything else I can think of with every event possible,
onload, onactivate, Is there a better way?

2nd question. What is the difference between refresh and requery.

Thanks,
 
B

BrianPaul

The article deals with a combo box notinlist. My post is about a listbox.
However, The work around I did do does work. Was wondering if there was a
better way of doing it.

Question: If my form is already opened in the background.A popup form in
the forground doing the update, Is there another way to refresh, requery the
mainforms listbox without having to reopen the form. (Keep in mind the
mainform is never closed and is visible in the background)

Thanks
 
B

BrianPaul

Cool,

Thanks, Larry, I new there had to be a better way of doing it.

Now If I can just figure out why you would use Refresh VS Querry but not
having any particular problem just curious.

Thanks again Larry.
 
L

Larry Daugherty

You can do something like:

forms!MyFirstForm!MyListbox.Requery

in the Close event of the second form.

HTH
 
N

Niniel

BrianPaul, I'd be interested in your workaround, would you care to post here
what you did?

Thanks.
 
B

BrianPaul

Work Around method:

With a pop up form. On the oneventClick Command Button.

Just open the mainform again although its already in the background. then

use;

docmd.requery.yourlistbox
 
D

Dirk Goldgar

BrianPaul said:
Cool,

Thanks, Larry, I new there had to be a better way of doing it.

Now If I can just figure out why you would use Refresh VS Querry but
not having any particular problem just curious.

Refresh
----------
The Refresh method "refreshes" the records currently displayed by a
form, so that the form will show any changes made to those records by
other users since the form was loaded. However, Refresh doesn't rerun
the query that loaded the form, so any new records (created by other
users, or by your own code) that might meet the criteria of the form's
recordsource will not be displayed, and any records that were deleted
externally, or modified so they no longer meet the criteria, will still
be displayed on the form. Records that have been deleted by external
means will show on the form with "#Deleted" in all fields.

The Refresh method saves the current record on the form, if it's dirty,
and then reloads all the records from their source table(s). People
sometimes call the Refresh method just to force the current record to be
saved. I don't think that's a good practice, however, as it's
inefficient to do all that and there are simpler, more specific ways to
force a record save.


Requery
-----------
The Requery method reruns the query that loaded a form, combo box, list
box, subform, or recordset. In this case, a completely new set of
records is loaded, so new records may appear and old records will
disappear if they no longer meet the query criteria. In the case of
requerying a form, the record pointer is reset to the first record.

Controls that have a domain aggregate functions or SQL aggregate
functions (e.g., DLookup(), DSum(), Sum(), Min(), etc.) as their
controlsources may also be requeried. In that case, the underlying
query that provides the data to the control is rerun.
 

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