After Update may not be the best choice. It will work for the current
record after updating TextA, but when you move to a new record the update
will not occur. TextB will show the value from the last time TextA was
updated, no matter the current value of TextA, until you update TextA. You
would need the same code in the Current event to make each record show the
correct value as soon as you go to the record.
I just now learned about the Choose function. It seems to be the cleanest
solution. You can place the expression Douglas Steele suggested into the
Control Source of an unbound text box, except substitute the name of your
TextA field for A:
=Nz(Choose([TextA], 1, .7, .33), 0)
You could also use the same expression in a query. At the top of a blank
column in query design view:
ViewPercent: Nz(Choose([TextA], 1, .7, .33), 0)
Base your form on the query, and bind a text box to ViewPercent (i.e. use
ViewPercent as its Control Source).
In either case, format the text box for Percent.
Help has more information about Choose and Nz.
I will assume that in asking about VB you are asking about a way to produce
the desired result rather than specifically about using VBA. As I said, VBA
would require some extra work, and from what I can see it offers nothing you
can't get from an expression.
Pete said:
Thanks so far. Is the VB code written against text[A] on update? If so, is
it
possible to specify the precise code written?
Douglas J. Steele said:
There's also the Choose function that could be utilized in this case:
=Choose(A, 1, .7, .33)
Note that that will return Null if A is other than 1, 2 or 3. To have it
return 0 (as in Bruce's example), you can use
=Nz(Choose(A, 1, .7, .33), 0)