Recalc or requery?

F

Frank Martin

I wonder what the difference between these two are?
Sometimes one works and sometimes the other.

When I am testing a form with combos I check the requery/recalc by pressing
the F9 button and then try to resolve this back to code with, eg, Me.Requery
or Me.Recalc or Combo(x).Requery etc.

I get inconsistant results and sometimes we are reduced to pressing the F9
key to update a Combo rowsource query!

Is there some definitive solution?

Please help, Frank who has Access2000
 
A

Allan Murphy

Frank

Try the following code

docmd.requery "the name of your combo"



Allan Murphy
Email: (e-mail address removed)
 
B

Bob Howard

The Requery method tells Access to go and re-fetch the data underlying the
query since something may have changed since it was last queried (or form
opened).
 
D

Dirk Goldgar

Frank Martin said:
I wonder what the difference between these two are?
Sometimes one works and sometimes the other.

When I am testing a form with combos I check the requery/recalc by
pressing the F9 button and then try to resolve this back to code
with, eg, Me.Requery or Me.Recalc or Combo(x).Requery etc.

I get inconsistant results and sometimes we are reduced to pressing
the F9 key to update a Combo rowsource query!

Is there some definitive solution?

Please help, Frank who has Access2000

The Recalc method causes all calculated controls on the form to be
reevaluated.

The Requery method of a form causes the form's recordsource query to
rerun, possible returning a different set of records.

The Requery method of a combo or list box causes the control's rowsource
query to be rerun, possibly returning a different set of records for the
control's list.

The Requery method of a subform or OLE object causes the query on which
that object is based to be rerun.

The Requery method of a control for which the ControlSource includes a
domain aggregate function (e.g., DLookup(), DCount()) or a SQL aggregate
function (e.g., Count() or Sum()) causes the underlying or implicit
query to be rerun.

Calling the Requery method of any other object or control causes the
form itself to be requeried.
 
F

Frank Martin

Dirk Goldgar said:
The Recalc method causes all calculated controls on the form to be
reevaluated.

The Requery method of a form causes the form's recordsource query to
rerun, possible returning a different set of records.

The Requery method of a combo or list box causes the control's rowsource
query to be rerun, possibly returning a different set of records for the
control's list.

The Requery method of a subform or OLE object causes the query on which
that object is based to be rerun.

The Requery method of a control for which the ControlSource includes a
domain aggregate function (e.g., DLookup(), DCount()) or a SQL aggregate
function (e.g., Count() or Sum()) causes the underlying or implicit
query to be rerun.

Calling the Requery method of any other object or control causes the
form itself to be requeried.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Many thanks for this, but what is the best way to requery a combo box, is
it:
On Enter,
On got Focus,
On before Update,
Or some other..?

We have code already instructing the cursor to appear in a combo box when a
form/subform is opened, and so it musn't conflict with this.
Regards Frank
 
F

Frank Martin

Thanks, I am testing this now.
Frank

Allan Murphy said:
Frank

Try the following code

docmd.requery "the name of your combo"



Allan Murphy
Email: (e-mail address removed)
 
D

Dirk Goldgar

Frank Martin said:
Many thanks for this, but what is the best way to requery a combo
box, is it:
On Enter,
On got Focus,
On before Update,
Or some other..?

We have code already instructing the cursor to appear in a combo box
when a form/subform is opened, and so it musn't conflict with this.

You're not asking what is the best way, you're asking what is the best
time. Clearly BeforeUpdate won't do, because you won't be able to enter
a value that isn't currently in the list, and so the BeforeUpdate event
won't fire. The *best* -- most efficient -- time would be whenever
something is added or subtracted from the combo box's rowsource, but if
you can't control that, it's probably safest to requery the combo box in
its Enter event. All you need is code along these lines:

Private Sub cboMyCombo_Enter()

Me!cboMyCombo.Requery

End Sub
 

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

Similar Threads


Top