How to create an automated field

Anauaton

New member
Local time
Today, 21:32
Joined
Dec 6, 2009
Messages
8
Hi, I am new on Access, never been taught anything about it so please pardon my vocabulary.

I am creating a certain number of fields on a form, like 6, and each of them is configured to receive an integer between 1 and 5.

Now I want to create a 7th which should be an average of the 6 previous ones. It should be decimal, not integer, and should be automatically updated while I fill the previous fields.

Basically this field should not even be editable by the user filling the form, it should just provide an average real-time of the 6 other fields of this form, and this form only - not all the other data.

Is my question understandable?

Again, I just started creating my own database 6 weeks ago from scratch, never used Access before, it looks ok now though but I would really like to know how to create data that depend on other data, and not only on manual input.

please tell me if you can help me.

Thanks !
 
I think that you will need to use the after update event of each of the fields to run code

Me.field7=(Nz(me.field1,0)+nz(me.field2,0)+......nz(me.field6,0)/6

Brian

Set the property of field7 to locked to prevent changes and make it not a tab stop
 
Last edited:
I created an example database in this thread that might get you started, although your solution will be a little different, because it will involve OnChange events for individual edit boxes of a form. And if the DataSource for the form isn't a database in the file, you have to store variables for each of the six items in the form that can change, because OnChange only triggers when a data source changes, not when the item in an unbound edit box changes.

I hope this helps, or at least gives you a better place to start your next question from.

David
 
And if the DataSource for the form isn't a database in the file, you have to store variables for each of the six items in the form that can change, because OnChange only triggers when a data source changes, not when the item in an unbound edit box changes.

David

Not true the after update triggers for unbound text boxes so that can be used.
 
Not true the after update triggers for unbound text boxes so that can be used.
Oops. I was being a bit dyslexic, because the 'OldValue' is not reflected correctly for unbound items, so it was worthless for my project, and I simply applied that 'worthless' across the board. But for the OP, they shouldn't care about the OldValue, so you are correct and it can be used. Sorry for the confusion.
 
I think that you will need to use the after update event of each of the fields to run code

Me.field7=(Nz(me.field1,0)+nz(me.field2,0)+......nz(me.field6,0)/6

Brian

Set the property of field7 to locked to prevent changes and make it not a tab stop

Waouh it works.

thanks so much !!!!!!!!

Thanks to all other answers.
 
And this is a case where you should NOT be storing the field value, but calculating it in a query.
 

Users who are viewing this thread

Back
Top Bottom