Calculated or Entered Value

B

Bill

Hi All,

Is there anyway to have a field in a table as either a calculated or an
entered value. I'm thinking of a circumstance where if a value is present in
another the value is calculated, otherwise it is entered. Or am I missing
something really basic!!

Cheers.
Bill
 
J

John Spencer

You can't do that in a query or a table, but you can do it on a form
using VBA to assign a value to a control bound to a field or allowing
you to type directly into the control.

You would probably need to assign the value in the form's current event
and if the source field value was enterable then in the after update
event of the control bound to the source field.



'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 
R

Rick Brandt

Bill said:
Hi All,

Is there anyway to have a field in a table as either a calculated or
an entered value. I'm thinking of a circumstance where if a value is
present in another the value is calculated, otherwise it is entered.
Or am I missing something really basic!!

Cheers.
Bill

You can do this in a form which is where all data entry should happen.

In the AfterUpdate event of the "other" control you perform the calculation
and push the result into the control that should hold that value.

In the BeforeUpdate event of the control holding your calculated value you
can check to see if a value is present in the other control and if so...

MsgBox "Manual Entry Not Allowed"
Cancel = True
Me.ControlName.Undo

As long as the other control is empty then manual entry would be allowed.
 

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