Forcing field write

rjf3123

Registered User.
Local time
Today, 11:43
Joined
Oct 4, 2003
Messages
25
have a datasheet form with about 10 fields.

When I enter data into field 2 for example, is there a way for me to "force write" that data into the table after I make a change and tab to the next field?

I have calculations in following fields that rely on the data from field 2.

Currently, when I enter or change data in field 2, tab to the next field then look at the table, there is no data written to the table. When I tab through the end of the record to field 1 of the next record is when I see the data written.

Looking for a force flush or a force write of some sort.

This is a datasheet form and not a screen painted form.

Any ideas?

TIA -
R. Fisher
 
You could place code in the After Update event of the field and force the record to be written to the underlying table using a DoCmd.RunCommand acCmdSave.

However, I must ask why you don't base your form calculations on the form fields themselves rather than referring to the stored fields in the table. What I mean is, if you have say, a form field called "txtPrice" and you want to multiply it by a percent to get a marked up price you should be referencing the form field and not the field from the underlying table that feeds into the control.
 
dcx693 said:
You could place code in the After Update event of the field and force the record to be written to the underlying table using a DoCmd.RunCommand acCmdSave.

Code:
DoCmd.RunCommand acCmdSaveRecord
 
Thanks all -
the acCmdSaveRecord did the trick.

dcx - in response to your question of why I am trying to do this ...

First off, I am an access hacker! I know what I am trying to accomplish but ain't always sure it's the best approach.

What I have is a form with a couple tab pages. Each tab page is a subform. Each subform has fields that are either read out of the appropriate table or simply displayed as a calculation.

Problem I was encountering was there are times I would only have to update one field on say Page 1, Subform 1 which reads/writes info into Table 1. After the update (field lost focus), I run an update query to update Table 2 with the info from the field I just changed. Was finding the update query wasn't adding or changing the field info on table 2 'cause the field I just modified in table 1 hadn't been written to the table yet.

I know there are probably smarter ways of doing this, but again, remember I am just an Access hacker!!!

Relationships are probably the direction I should be looking but I haven't gotten that far yet in my education - truth-be-told, I have a relationship phobia (but that's another story)!!

Anyhow -
Thanks again for the solution!

R. Fisher
 

Users who are viewing this thread

Back
Top Bottom