Automatically update calculated fields in a subform

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

Guest

I have a subform datasheet in which I enter a date and an odometer reading. A
VBA code runs in the background to calculate a) the partial miles since the
last entry date as well as b) the total miles accumulated since the very
first entry date.

My problem is that I can only get the partial and total miles fields to
update by closing and then reopening the form.

I am sure that there is a simple code like requery or refresh which can be
placed somewhere within the subform to calculate these fields automatically
as soon as the odometer data is entered ... only I am not smart enough to
figure out what command is needed and what event to attached it to. Can any
one help me?
 
Use the .Requery method for the control as in

[Forms]![mainForm]![subform].form![controlName].requery

I would place the code in the AfterUpdate event for the Odometer data
 
Thank you David for your help. I am continually impressed by the expert
service provided at this site.

David C. Holley said:
Use the .Requery method for the control as in

[Forms]![mainForm]![subform].form![controlName].requery

I would place the code in the AfterUpdate event for the Odometer data
I have a subform datasheet in which I enter a date and an odometer reading. A
VBA code runs in the background to calculate a) the partial miles since the
last entry date as well as b) the total miles accumulated since the very
first entry date.

My problem is that I can only get the partial and total miles fields to
update by closing and then reopening the form.

I am sure that there is a simple code like requery or refresh which can be
placed somewhere within the subform to calculate these fields automatically
as soon as the odometer data is entered ... only I am not smart enough to
figure out what command is needed and what event to attached it to. Can any
one help me?
 
I'm not Access programmer but got the task to fix some function after Access
upgrade from 97 to 2003. A related question, function A (name = ElementX,
source control = Company, an existing query generates company list), status:
working; function B (name = ElementY, source control = Products, an existing
query generates product list based on FUNCTION A's company selection, status:
not working. Before the upgrade both functions worked. How to fix it? Slow
down when explaining it for I'm not an Access guy or VBA programmer.

TIA

David C. Holley said:
Use the .Requery method for the control as in

[Forms]![mainForm]![subform].form![controlName].requery

I would place the code in the AfterUpdate event for the Odometer data
I have a subform datasheet in which I enter a date and an odometer reading. A
VBA code runs in the background to calculate a) the partial miles since the
last entry date as well as b) the total miles accumulated since the very
first entry date.

My problem is that I can only get the partial and total miles fields to
update by closing and then reopening the form.

I am sure that there is a simple code like requery or refresh which can be
placed somewhere within the subform to calculate these fields automatically
as soon as the odometer data is entered ... only I am not smart enough to
figure out what command is needed and what event to attached it to. Can any
one help me?
 
please post this as a separate thread - as it is a separate issue and
PLEASE be certain to post the code for both functions.
I'm not Access programmer but got the task to fix some function after Access
upgrade from 97 to 2003. A related question, function A (name = ElementX,
source control = Company, an existing query generates company list), status:
working; function B (name = ElementY, source control = Products, an existing
query generates product list based on FUNCTION A's company selection, status:
not working. Before the upgrade both functions worked. How to fix it? Slow
down when explaining it for I'm not an Access guy or VBA programmer.

TIA

:

Use the .Requery method for the control as in

[Forms]![mainForm]![subform].form![controlName].requery

I would place the code in the AfterUpdate event for the Odometer data
I have a subform datasheet in which I enter a date and an odometer reading. A
VBA code runs in the background to calculate a) the partial miles since the
last entry date as well as b) the total miles accumulated since the very
first entry date.

My problem is that I can only get the partial and total miles fields to
update by closing and then reopening the form.

I am sure that there is a simple code like requery or refresh which can be
placed somewhere within the subform to calculate these fields automatically
as soon as the odometer data is entered ... only I am not smart enough to
figure out what command is needed and what event to attached it to. Can any
one help me?
 
Thanks, David, I've posted a new thread entitled "Related field Data
Population Failed in ...".

David C. Holley said:
please post this as a separate thread - as it is a separate issue and
PLEASE be certain to post the code for both functions.
I'm not Access programmer but got the task to fix some function after Access
upgrade from 97 to 2003. A related question, function A (name = ElementX,
source control = Company, an existing query generates company list), status:
working; function B (name = ElementY, source control = Products, an existing
query generates product list based on FUNCTION A's company selection, status:
not working. Before the upgrade both functions worked. How to fix it? Slow
down when explaining it for I'm not an Access guy or VBA programmer.

TIA

:

Use the .Requery method for the control as in

[Forms]![mainForm]![subform].form![controlName].requery

I would place the code in the AfterUpdate event for the Odometer data

TPP wrote:

I have a subform datasheet in which I enter a date and an odometer reading. A
VBA code runs in the background to calculate a) the partial miles since the
last entry date as well as b) the total miles accumulated since the very
first entry date.

My problem is that I can only get the partial and total miles fields to
update by closing and then reopening the form.

I am sure that there is a simple code like requery or refresh which can be
placed somewhere within the subform to calculate these fields automatically
as soon as the odometer data is entered ... only I am not smart enough to
figure out what command is needed and what event to attached it to. Can any
one help me?
 
Back
Top