Setting a value in a “continues form” or in a “datasheet view”

  • Thread starter Steve Rensiem via AccessMonster.com
  • Start date
S

Steve Rensiem via AccessMonster.com

This should be a standard question but i could not find it anywhere.

How do I set a value to a text box in a continues form or in a datasheet
view for each individual row.

Example:
employee_name Hours_worked Hourly_wage total

when entering hours_worked and hourly_wage it should calculate the total
for that row.

(the default value for hourly_wage should also be set using a dlookup)

Thank you
Steve
 
J

John Vinson

This should be a standard question but i could not find it anywhere.

How do I set a value to a text box in a continues form or in a datasheet
view for each individual row.

Example:
employee_name Hours_worked Hourly_wage total

when entering hours_worked and hourly_wage it should calculate the total
for that row.

(the default value for hourly_wage should also be set using a dlookup)

Thank you
Steve

The Total should NOT be stored in your table.

Storing derived data such as this in your table accomplishes
three things: it wastes disk space; it wastes time (almost
any calculation will be MUCH faster than a disk fetch); and
most importantly, it risks data corruption. If one of the
underlying fields is subsequently edited, you will have data
in your table WHICH IS WRONG, and no automatic way to detect
that fact.

Just redo the calculation whenever you need it, either as a
calculated field in a Query or just as you're now doing it -
in the control source of a Form or a Report textbox.

Just set the Control Source of the Total textbox to

=[Hours_Worked] * [Hourly_Wage]

You can set the Default property of the Hourly_Wage textbox to the
DLookUp expression.

John W. Vinson[MVP]
 
S

Steve Rensiem via AccessMonster.com

thank you john,

I guess I did not explain the question.

my question was: when entering the values in these fiels it should calculte
all rows individually.

Example

Emp_name hours wage total
steve 20 20 400
Brian 10 35 350
seanD 22 18 396

Instead it would return
steve 20 20 400
Brian 10 35 400
seanD 22 18 400

basically my question is how do I reference a record individually. if i
would set the control source of [total] to "=[Hours_Worked] * [Hourly_Wage]
" it will set all the [total] fields in the continues form to the same
value.
 
J

John Vinson

thank you john,

I guess I did not explain the question.

my question was: when entering the values in these fiels it should calculte
all rows individually.

Example

Emp_name hours wage total
steve 20 20 400
Brian 10 35 350
seanD 22 18 396

Instead it would return
steve 20 20 400
Brian 10 35 400
seanD 22 18 400

basically my question is how do I reference a record individually. if i
would set the control source of [total] to "=[Hours_Worked] * [Hourly_Wage]
" it will set all the [total] fields in the continues form to the same
value.

Odd. It shouldn't!

What you can do is base the Subform on a Query using a calculated
field: just put

Total: [Hours] * [Wage]

in a vacant field cell in the query, and bind a textbox to this
calculated field.

John W. Vinson[MVP]
 

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