Refresh, Requery, Repaint?? Which One?

N

Nick

OK, This has to be simple. I have checked my Idiot's Guide, searched as best
I can the internet and this forum, and still unsure where to go.

PROBLEM:

I have a form that uses a DLookUp to demonstrate a total from another table.
No problem so far, that works fine. However, if I change a value in the form,
it should change the value in the query that runs the DLookUp.

When I use Requery in the AfterUpdate properties in the relevant controls
(ie, project total), this all works fine. However, Requery sets the Form back
to the first record! This will be very annoying as the more and more data
gets entered.

What I want to do is essentially a "Requery Style" update to the form and
table in order to allow the DLookUp.

Furthermore - I have another table, same problem. This is a Purchase Order
Table. I have a report that prints the current purchase order based on the
Purchase Order Number on the form (acting as a parameter in the Purchase
Order Query that drives the Report); however, the report does not print
anything unless it is updated, and requery sends me back to the start, not
the purchase order I am (was) looking at.

So: Do I use Repaint or Refresh, or can I just use the RunCommand to save
the form and then do it. The DLookUp does not work with the RunCommand save
(already tried it) and seems to need something like a Requery, but the other
form? Does RunCommand Save do it, or Repaint/Refresh?

Cheers
 
E

ErezM via AccessMonster.com

hi
for the dlookup textbox - if the data it looks for is currently edited then
use the form's AfterUpdate event to MyDlookupTextBox.Requery (you requery
only the control itself and not the form's recordset)
if you need to "flush" the updates to the underlying tables before a report
is opened, then yes, the Docmd.RunCommand ACCMDSaveRecord is the choice for
you

good luck
 
N

Nick

ErezM,

Cheers. The below works fine and does the job very well. I also (since I had
no internet last night and had some time) was able to answer my own question
by "trial and error"! I have ended up using both the below and Refresh (now I
understand the difference between the three) for the second table.

Cheers
 

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