auto value in a field

  • Thread starter Dimitris Nikolakakis
  • Start date
D

Dimitris Nikolakakis

I have the following tables:

Clients (ID, Name)
Factories (ID, Name)
ClientDiscounts (ClientID, FactoryID, Discount)

I have a form where the user selects ClientID, FactoryID (these are combo
boxes).
On the form I have a field Discount.

How can I update the field when the user selects Client and Factory?


Thanks
 
P

peter walker

Create a vba function to look at the combos and use a recordset to retrieve
the discount. You include code in the function to check to see if *both*
combos have valid data, if not then return zero discount. You call the
function from the after update event of each combo to update the field on
the form. This could actually happen twice, once as the first combo value is
selected, then again for the second one. First time around it updates
discount to zero but when the second combo is done the proper discount will
be plugged in. It has to be this way to allow you to change either of the
combos (for a correction) and still get the right value. The form before
update can check to see both combos were correctly selected before saving
the record.

--

peter walker MVP

Please post replies to the news group so everyone can benefit.
www.papwalker.com
 

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