Re: How to Update Main when Closing Pop

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



<doyle60@xxxxxxx> wrote in message
news:62799831-3538-4b78-9214-b2d546bb8e0d@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Thanks.

This seems a little harder than I wanted. Why is it that I just can't
write code on the on close event of the pop up that requeries the
main? When I thought to do this, I never imagined it would ever be so
involved.


You mean my suggestion of ONE LINE of code is involved?

If one line of code is too much, then there not a lot I can do to help you
here...

My example suggestion means that you don't have to put ANY code in the close
event of the form that was just opened. Why would you want or desire to
write a whole whack of code for every form that the current form just
opened? The example I gave also works great because if you do things like
change the forms name, copy it to another application, there is no
"dependent" code needed to be placed in any other form. As I said, I don't
know why you think ONE LINE of code in the form activate event is "so
involved"

My solution allows your own form to launch 1, 2, or 10 different forms, and
when any of them returns back, a me.refreash is executed. This will update
any changes that have occurred to data on the "main" form in question.


I sort of just want a general code that updates this form without it
loosing the record it is on.


Yes, the one line of code I suggested in the forms activate event will do
the trick. The "only" caveat you have to worry about is to ensure you force
a disk write **if** the form you are launching has the ability to
edit/modify the record that the calling form was on.

So,

me.Refresh

Will do what you want. Refresh will display any changes made to the data
displayed by the current form...in fact, this works even in the case of
continues form.

Now, it is entirliary possible that your left out some MAJOR details here.
Such as the 2nd form being launched is not just possible editing the current
record, but is in fact adding new records?

Anyway, me.Refresh in the forms activate event will refresh and display any
changes that have occurred to the form's data. If you need the forms
reocrdset to display "new" added reocrds, but still remain on the current
record (that is diffent question on your part by the way), then in place of
me.fresh, you can place a public function in the forms code module that is:


Public function MyRequery

dim lngID as long


lngID = me!id
me.Requery
me.Recordset.FindFirst "id = " & me!id

end if


The above assumes a pk ID of id (which is the default).


So, in the current form (the activate event) you can now go:

me.MyRefresh


If you need a button, or for some strange un-known reason you can't use the
forms activeVate event, then you can go from another form:

forms!NameOfForm.Form.MyRefresh


Perhaps I need a module for this? If so, what would be the code for
that?

As mentioned, if you just looking to have a form update any changes made to
the current record it is on, then a me.Refresh will do the trick.

If you need the form to display additional records added, then use the
public function idea I listed above...


Is there an easier, more general approach?


Gee, more general then my original suggestion? I been in eh IT business for
about 20 years, and a one line code solution that will refresh when you
return from ay form...hum, I don't think that kind of solution can be
beat...



--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@xxxxxxx


.


Quantcast