concerning subforms...

N

Neal Tipton

Group:

1. What is happening when I have to go to the menu bar and select
"records -- refresh" in order to see the contents of my subforms?
2. What's the difference between refresh and requery and why does the Me.
object in VBA have both, but Me.someobjecthere has only the requery method
as an option?
3. How do you reference objects in subforms via VBA?

Thanks,
Neal
 
A

Albert D. Kallal

Neal Tipton said:
Group:

1. What is happening when I have to go to the menu bar and select
"records -- refresh" in order to see the contents of my subforms?

For a form, you have:

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 dies 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. However, to write
the current record to disk, a lot 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
me.fresh.

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. However, 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...

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


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.
3. How do you reference objects in subforms via VBA?

To force the sub-form to reload and display some records you added (say via
code), you would use:

me.MySubFormControlName.form.Requery

I most certainly have used the above syntax...as sometimes I want to make
the sub-form display new records that I added via some code.

So, my code might look like:

me.Refresh ' force current main form record to disk
Call CoolProcessing ' this could a sub that does all kinds of stuff,
'and adds some sub-form records. However, to make
' sure that the sql used in the CoolProcessing
subroutine
' has the most update data...I forced the main form
to
' write to disk with me.refresh.

me.MySbFormControlName.Form.Requery

I used Requery for the sub-form since it likely has "many" records...where
as I used refresh on the main form to simply force a disk write...
 

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

Someone stop my subforms from requerying 1
link subforms 2
Requery 1 subform from another. 13
Refresh, requery, or what? 2
Pls help requery subform 2
subforms not requerying 6
Tab Subforms 2
Subforms and requery 2

Top