Refreshing Function in realtime.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I've written a function which returns a text string based upon the SourceObject and LinkChildFields of a subform. The purpose of this function is just to change the label above the subform on my main form to say whats currently in the subform. I want this function to be able to refresh to its new value when i change the SourceObject of the subform but I'm not sure how. I don't want to requery my main form

Is there a trick to getting a function used in a single unbound field to refresh without anything else being affected

Thanks

Bill
 
Hum, I don't think you want requery.

But, here is a rundown of the methods for a form, one of them should work
for you!

me.Refresh
' writes current record to disk, and display any updates to
existing data. I often use this command to force a disk write. It does NOT
loose your current record position, and it DOES NOT load, or show new
records that have been added. I use this command a lot (far more then
any of the following commands). In fact, anytime I launch another form
from the existing form, I force a disk write using this command.
(when you come back to the form, you never get one those data
has been modified prompts). Further, it is safer, as each form
writes its data before you leave, and any un-proper shutdown
will NOT loose data from the previous 4 or 5 forms that might
be open.

However, to write
the current record to disk, a lot developers also use:

if me.Dirty = True then
me.Dirty = false
end

Since I find it easer to type in me.Refresh...I use me.Refresh a lot
(however, my access designs are very good, and USUALLY only ONE RECORD is
attached and viewable in the form. If you have poor designs, or simply open
a form to a large table...then I would use the dirty code sample in place of
the less typing me.refresh.

me.Repaint
' Displays any data on the screen that needs to be re-plotted. This
can include calculated text boxes etc. I don't think I have EVER used this
command. It has NOTHING to do with forcing a disk write, or showing data
that have been changed. However, I suppose for un-bound forms, it might be
of use...or perhaps in large processing loops where you want some things to
display on the screen, and you changed a control value. Most of the time
you are FAR better off to simply flush out the events buffer with DoEvents.
So, I would use DoEvents in place of me.Repaint, as it allows all pending
events to fire. Again, in your case this is likely not the ticket.

me.Recalc
' This one forces all calculated controls on the screen to re-calc.
Kind of the re-calc option in Excel. Again...I generally just use DoEvents

- You might give me.Recalc a try. If you function does NOT have
any static variables, or (or global - yuk!), then the above should
do the trick.

me.Requery
' This causes the form to complete re-load the reocrdset. So, this
is kind like closing the form, and re-opening it. You also loose your
current record position. Bookmarks also become invalid when you do this. It
will show any new records added.
 
Back
Top