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
John Spencer - 20 Apr 2008 15:24 GMT
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
'====================================================
> Hi All,
>
[quoted text clipped - 5 lines]
> Cheers.
> Bill
Rick Brandt - 20 Apr 2008 15:27 GMT
> Hi All,
>
[quoted text clipped - 5 lines]
> 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.

Signature
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Bill - 21 Apr 2008 16:28 GMT
Thanks both for the replies.
I will go and have a think!!!
Cheers.
Bill.