Input into one field to generate a value in another

C

CW

I have a costing form on which users will enter the description of crates to
be used, and the costs will be generated and totalled.
There are 10 lines and on some records there may be no crates, on others
there may be several.
There is a description field and then another field on each line that holds
the cost of the crate. This is a fixed amount of 60.00 for each crate that is
used.
I cannot use a default value of 60.00 as this would lead to a total of
600.00 on every record regardless of whether any crates had been specified or
not.
I want the value of 60.00 to appear automatically in the cost field on a
line ONLY if a user actually enters something in the description field on
that line.
It should not be triggered by the focus going into a description field, as a
user may well tab through all the lines as part of the page navigation.
I am assuming it needs a piece of code that will be kicked off On Change, or
something like that, in the Description field, and I have tried several
expressions but nothing worked!
I am sure this is quite simple and somebody will have the answer rightaway?
Many thanks
CW
 
A

Al Campagna

CW,
Make the default Price 0.00
Use the AfdterUpdate event of Decription...
If Not IsNull(Description) Then
Price = 60
Else
Price = 0
End if

If the user might delete the Description, Price would go back to zero.
 
C

CW

Thanks, Al, but this didn't work (at all). No error msge, no effect at all.
Any other suggestions, please!
 
A

Al Campagna

CW,
I tested the code, and it works, if your setup is as you stated, and you installed the
code properly.

This code will not effect any previously entered data. It works as you fill in, or
delete, the Description.
Go to any record without a Description, and add one... the Price will update to 60.
If you already have many records with a default price and no Desc, and you want to put
in Price if there is a description, and no Price if not, then you'll have to run a "one
time" Update query against the previous records. (using the same logic as my IF)
After that, each record will take care of itself as is is added.
 

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