Requery or Refresh?

  • Thread starter Slez via AccessMonster.com
  • Start date

S

Slez via AccessMonster.com

I have some calculated controls on a mainform that gets their values from
calculated controls in the footer of a subform. They are the sum of currency
fields. After records are entered into that subform, the values in the
mainform controls remain the same unless you close and reopen the mainform.
Is there a way to automatically keep those refreshed, requeried, or
recalculated? Perhaps after focus leaves the subform?

Thanks in advance for any help!
Slez
 
Ad

Advertisements

D

Damon Heron

In the afterupdate event of your subform, or a control in your subform, put
me.parent.recalc

HTH
Damon
 
S

Slez via AccessMonster.com

Thanks for your reply! It works...sort of...
It works perfectly if existing records are altered or new records are added
to the subform, but if a record is deleted, it does not recalc. Is there
anything that can be added to contend with that scenario? This scenario
doesn't happen too often, and users can refresh, but if I can get it to
automatically work, all the better!
Thanks again!
Slez

Damon said:
In the afterupdate event of your subform, or a control in your subform, put
me.parent.recalc

HTH
Damon
I have some calculated controls on a mainform that gets their values from
calculated controls in the footer of a subform. They are the sum of
[quoted text clipped - 7 lines]
Thanks in advance for any help!
Slez
 
D

Damon Heron

Lets back up a bit - if you have code similar to this in a textbox (here
called UnitsOnHand) in the subform's footer:
=Sum(nz([Dollars],0))

then a textbox on the main form should have this:
=nz([subfrmYourFormName].[Form]![UnitsOnHand],0)

and it will change automatically when records are added or deleted, no need
for any code.

There is a link between the main and subform, right?

Damon


Slez via AccessMonster.com said:
Thanks for your reply! It works...sort of...
It works perfectly if existing records are altered or new records are
added
to the subform, but if a record is deleted, it does not recalc. Is there
anything that can be added to contend with that scenario? This scenario
doesn't happen too often, and users can refresh, but if I can get it to
automatically work, all the better!
Thanks again!
Slez

Damon said:
In the afterupdate event of your subform, or a control in your subform,
put
me.parent.recalc

HTH
Damon
I have some calculated controls on a mainform that gets their values from
calculated controls in the footer of a subform. They are the sum of
[quoted text clipped - 7 lines]
Thanks in advance for any help!
Slez
 
S

Slez via AccessMonster.com

Looking back at my original post, I realize that I need to go into more depth
to explain how my forms/subforms work. I now know the reason why this must
not be working, but I'm not sure how it can be fixed.

I have a mainform, frmBid, which has a subform, BidLineItemSubfrom2, which is
INVISIBLE. I'll explain the reason for this shortly. Also on frmBid is a
command button, which opens up another mainform called frmBidItems. This
contains a subform called frmQryBidLineItems, which contains the subform
called BidLineItemSubfrom2. This is the path and location where users update
records.

So...I couldn't get the controls on frmBid to reference a subform located on
a different form. My fix was to insert BidLineItemSubfrom2 as a subform into
frmBid, but leave it Visible=No so that the records would exist within that
form. I made it visible and deleted on record, and sure enough, the
calculated controls updated imediately and as desired.

Having just the subform on frmBid appears to be the root of the problem.

If there was a way to get those controls to calculate without requiring the
invisible subform, that would be my ultimate solution!

Sorry for not fully explaining my form layout.
If you can still offer help, I'll greatly appreciate it!
Slez



Damon said:
Lets back up a bit - if you have code similar to this in a textbox (here
called UnitsOnHand) in the subform's footer:
=Sum(nz([Dollars],0))

then a textbox on the main form should have this:
=nz([subfrmYourFormName].[Form]![UnitsOnHand],0)

and it will change automatically when records are added or deleted, no need
for any code.

There is a link between the main and subform, right?

Damon
Thanks for your reply! It works...sort of...
It works perfectly if existing records are altered or new records are
[quoted text clipped - 18 lines]
 
Ad

Advertisements

D

Damon Heron

Without going into too much detail, here is an idea: Use a tabbed mainform
"frmBid", and make the frmBidItems a subform on the second tab, including
the subforms as part of the frmBidItems. This eliminates the need for an
invisible form, since it will exist on the main form as a subform. If for
some reason you don't want the user to have access to the second tab, you
can disable the tab unless certain conditions are met.

Finally, Google "syntax for main/subforms MS Access" to get some examples
of addressing the subforms, I have a list but don't know where I got it!


Damon

Slez via AccessMonster.com said:
Looking back at my original post, I realize that I need to go into more
depth
to explain how my forms/subforms work. I now know the reason why this
must
not be working, but I'm not sure how it can be fixed.

I have a mainform, frmBid, which has a subform, BidLineItemSubfrom2, which
is
INVISIBLE. I'll explain the reason for this shortly. Also on frmBid is a
command button, which opens up another mainform called frmBidItems. This
contains a subform called frmQryBidLineItems, which contains the subform
called BidLineItemSubfrom2. This is the path and location where users
update
records.

So...I couldn't get the controls on frmBid to reference a subform located
on
a different form. My fix was to insert BidLineItemSubfrom2 as a subform
into
frmBid, but leave it Visible=No so that the records would exist within
that
form. I made it visible and deleted on record, and sure enough, the
calculated controls updated imediately and as desired.

Having just the subform on frmBid appears to be the root of the problem.

If there was a way to get those controls to calculate without requiring
the
invisible subform, that would be my ultimate solution!

Sorry for not fully explaining my form layout.
If you can still offer help, I'll greatly appreciate it!
Slez



Damon said:
Lets back up a bit - if you have code similar to this in a textbox (here
called UnitsOnHand) in the subform's footer:
=Sum(nz([Dollars],0))

then a textbox on the main form should have this:
=nz([subfrmYourFormName].[Form]![UnitsOnHand],0)

and it will change automatically when records are added or deleted, no
need
for any code.

There is a link between the main and subform, right?

Damon
Thanks for your reply! It works...sort of...
It works perfectly if existing records are altered or new records are
[quoted text clipped - 18 lines]
Thanks in advance for any help!
Slez
 
Ad

Advertisements


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