Update Field Value 
Author Message
 Update Field Value

I have a field on a form whose value is determined by function that does a
summation query on a set of records in a table. If you enter this field, a
modal form is invoked that lets you modify the records that were the basis
of the value in the field. When you exit the modal form, the focus is still
set to the original field. I'm trying to figure out how get the field to
automatically update by re-invoking the function. I've played around with
just about all of the events for the field with no luck. For example, it
will update correctly if you shift focus to another field on the form but
that's not good enough. Is there an easy way to do this?

Thanx,
Garth



Wed, 12 Jan 2005 02:57:54 GMT  
 Update Field Value
Does issuing a Recalc on the form do the job?  E.g.,

    DoCmd.OpenForm "YourModalForm", WindowMode:=acDialog
    Me.Recalc

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Quote:
> I have a field on a form whose value is determined by function that does a
> summation query on a set of records in a table. If you enter this field, a
> modal form is invoked that lets you modify the records that were the basis
> of the value in the field. When you exit the modal form, the focus is
still
> set to the original field. I'm trying to figure out how get the field to
> automatically update by re-invoking the function. I've played around with
> just about all of the events for the field with no luck. For example, it
> will update correctly if you shift focus to another field on the form but
> that's not good enough. Is there an easy way to do this?

> Thanx,
> Garth



Wed, 12 Jan 2005 03:23:07 GMT  
 Update Field Value
Sorry this is so complicated to describe. The problem is not with the modal
form for editing the records. Its the field in the form underneath that
needs to get recalculated when the modal form is exited. The modal form is
used to manipulate the set of records that are summed to establish the value
of the lower-level field. When the modal form has completed modifying the
records and is exited, the original field, which still has the focus, needs
to be recalculated. The prob seems to be in firing off an event that I can
use to update the field. This isn't happening because the focus of the
original field is never lost or changed by the modal form.

Clear as mud?

:-)


Quote:
> Does issuing a Recalc on the form do the job?  E.g.,

>     DoCmd.OpenForm "YourModalForm", WindowMode:=acDialog
>     Me.Recalc

> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com

> (please reply to the newsgroup)



> > I have a field on a form whose value is determined by function that does
a
> > summation query on a set of records in a table. If you enter this field,
a
> > modal form is invoked that lets you modify the records that were the
basis
> > of the value in the field. When you exit the modal form, the focus is
> still
> > set to the original field. I'm trying to figure out how get the field to
> > automatically update by re-invoking the function. I've played around
with
> > just about all of the events for the field with no luck. For example, it
> > will update correctly if you shift focus to another field on the form
but
> > that's not good enough. Is there an easy way to do this?

> > Thanx,
> > Garth



Wed, 12 Jan 2005 03:36:57 GMT  
 Update Field Value
This seems perfectly clear to me, and is the way I understood it before.
Did you try what I suggested?  If the control in question is a calculated
control (i.e., its controlsource begins with "="), then recalculating the
form with Me.Recalc should cause it to be recalculated.  If you are opening
your form in dialog mode (using the WindowMode:=acDialog argument to
OpenForm), then the code in the calling form will wait until that form is
closed or made invisible before proceeding, so whatever code you eventually
use to recalculate the field can simply be placed after the DoCmd.OpenForm
call, and it will be executed when that form is closed.

It is possible, I suppose, that you might need to refresh or requery your
form after the modal form is closed, and then recalculate, depending on what
your modal form is actually doing and what sort of calculation is giving
your field its value.  Or if your "calculated" field really isn't a
calculated field in the technical sense at all, but has a value assigned to
it by a calculation and assignment you perform in code, then you'll need to
perform that calculation and assignment again.

If my suggestion didn't work, maybe you could post the controlsource
expression of the field, or the code that calculates and assigns a value to
it.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Quote:
> Sorry this is so complicated to describe. The problem is not with the
modal
> form for editing the records. Its the field in the form underneath that
> needs to get recalculated when the modal form is exited. The modal form is
> used to manipulate the set of records that are summed to establish the
value
> of the lower-level field. When the modal form has completed modifying the
> records and is exited, the original field, which still has the focus,
needs
> to be recalculated. The prob seems to be in firing off an event that I can
> use to update the field. This isn't happening because the focus of the
> original field is never lost or changed by the modal form.

> Clear as mud?

> :-)



> > Does issuing a Recalc on the form do the job?  E.g.,

> >     DoCmd.OpenForm "YourModalForm", WindowMode:=acDialog
> >     Me.Recalc

> > --
> > Dirk Goldgar, MS Access MVP
> > www.datagnostics.com

> > (please reply to the newsgroup)



> > > I have a field on a form whose value is determined by function that
does
> a
> > > summation query on a set of records in a table. If you enter this
field,
> a
> > > modal form is invoked that lets you modify the records that were the
> basis
> > > of the value in the field. When you exit the modal form, the focus is
> > still
> > > set to the original field. I'm trying to figure out how get the field
to
> > > automatically update by re-invoking the function. I've played around
> with
> > > just about all of the events for the field with no luck. For example,
it
> > > will update correctly if you shift focus to another field on the form
> but
> > > that's not good enough. Is there an easy way to do this?

> > > Thanx,
> > > Garth



Wed, 12 Jan 2005 03:57:50 GMT  
 Update Field Value
Your initial reply gave me the correct approach. I was not using the DoCmd
inline from the event code of the field in question but was instead doing
"Set frmEV = New Form_frmQTYEvent" in a called subroutine from the event of
the field and then doing "Set frmEV = Screen.ActiveForm" as the last
statement of the called function. The result was that the event code of the
field was immediately completing without waiting for the modal form to exit.
I am now using your example and all is working correctly.

Thanx!
Garth


Quote:
> This seems perfectly clear to me, and is the way I understood it before.
> Did you try what I suggested?  If the control in question is a calculated
> control (i.e., its controlsource begins with "="), then recalculating the
> form with Me.Recalc should cause it to be recalculated.  If you are
opening
> your form in dialog mode (using the WindowMode:=acDialog argument to
> OpenForm), then the code in the calling form will wait until that form is
> closed or made invisible before proceeding, so whatever code you
eventually
> use to recalculate the field can simply be placed after the DoCmd.OpenForm
> call, and it will be executed when that form is closed.

> It is possible, I suppose, that you might need to refresh or requery your
> form after the modal form is closed, and then recalculate, depending on
what
> your modal form is actually doing and what sort of calculation is giving
> your field its value.  Or if your "calculated" field really isn't a
> calculated field in the technical sense at all, but has a value assigned
to
> it by a calculation and assignment you perform in code, then you'll need
to
> perform that calculation and assignment again.

> If my suggestion didn't work, maybe you could post the controlsource
> expression of the field, or the code that calculates and assigns a value
to
> it.

> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com

> (please reply to the newsgroup)



> > Sorry this is so complicated to describe. The problem is not with the
> modal
> > form for editing the records. Its the field in the form underneath that
> > needs to get recalculated when the modal form is exited. The modal form
is
> > used to manipulate the set of records that are summed to establish the
> value
> > of the lower-level field. When the modal form has completed modifying
the
> > records and is exited, the original field, which still has the focus,
> needs
> > to be recalculated. The prob seems to be in firing off an event that I
can
> > use to update the field. This isn't happening because the focus of the
> > original field is never lost or changed by the modal form.

> > Clear as mud?

> > :-)



> > > Does issuing a Recalc on the form do the job?  E.g.,

> > >     DoCmd.OpenForm "YourModalForm", WindowMode:=acDialog
> > >     Me.Recalc

> > > --
> > > Dirk Goldgar, MS Access MVP
> > > www.datagnostics.com

> > > (please reply to the newsgroup)



> > > > I have a field on a form whose value is determined by function that
> does
> > a
> > > > summation query on a set of records in a table. If you enter this
> field,
> > a
> > > > modal form is invoked that lets you modify the records that were the
> > basis
> > > > of the value in the field. When you exit the modal form, the focus
is
> > > still
> > > > set to the original field. I'm trying to figure out how get the
field
> to
> > > > automatically update by re-invoking the function. I've played around
> > with
> > > > just about all of the events for the field with no luck. For
example,
> it
> > > > will update correctly if you shift focus to another field on the
form
> > but
> > > > that's not good enough. Is there an easy way to do this?

> > > > Thanx,
> > > > Garth



Wed, 12 Jan 2005 05:10:13 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Updating Field Values

2. Updating Field Values

3. Updating Field Values

4. Updating Field Values

5. adodb connection to excel: recordset.fields(i).value=null for fields with numeric value

6. adodb connection to excel: recordset.fields(i).value=null for fields with numeric value

7. adodb connection to excel: recordset.fields(i).value=null for fields with numeric value

8. Updating field in form from summary value in another

9. Help with updating a field value

10. Updating Fields with Different Values?

11. Variable and field value changes after .Update in VBA

12. need help on getting the auto-increment value of a field BEFORE updating recordset

 

 
Powered by phpBB® Forum Software