This is probably another stupid thing for me. But I have watched the Expert 9 video Numerous times and I can't get the discount rate to cascade down to the order detail form. I can get it to cascade to the order form from the customer Form but not from the order form to the order detail form. I have tried to get the information from the customer form to put it on the order detail Form and it still does not work. Which leads me to believe that it is something in the order detail form. I will include the screenshots of the forms and the discount rate properties.
Richard Van WagonerOP
@Reply 2 years ago
Richard Van WagonerOP
@Reply 2 years ago
Sami Shamma
@Reply 2 years ago
Richard,
please share screen shot of Customer, Order and Order Details tables in Design view
Richard Van WagonerOP
@Reply 2 years ago
Richard Van WagonerOP
@Reply 2 years ago
Richard Van WagonerOP
@Reply 2 years ago
Sami Shamma
@Reply 2 years ago
what happens when you add a new order detail line?
Richard Van WagonerOP
@Reply 2 years ago
The discount stays at 0%
Kevin Yip
@Reply 2 years ago
Create ANOTHER new record and see what it shows.
A default value is set BEFORE a new record is created. If the default value changes, you have to make another new record in order to get the new default value.
Richard Van WagonerOP
@Reply 2 years ago
I have tried that the discount rate stays at Zero no matter what unless I change it manually.
Kevin Robertson
@Reply 2 years ago
In the After Update event of the DiscountRate on OrderF Requery the Subform
OrderDetailF.Requery
Do you have any other code that could be preventing the field getting the Default Value?
Kevin Yip
@Reply 2 years ago
Here is an example of what can happen, and why a default value is not the best way to do this kind of thing:
Suppose your customer form has 2%, your OrderF shows 2%, so your subform should also show 2%. That's according to how you set up default values.
If you navigate to different customer that has 4%, your order main form and subform will STILL show 2%. Navigate to customer with 10%, you will still get 2% on the order forms. You can do this *forever* and your order forms will show the old default value 2%.
That's because default values are *static*. It is only calculated *once*: when a *new blank row* is created.
The only way to get rid of 2% is to enter and save the record in the order forms, so Access will create a *new blank record* on the form. Then and only then will a new default value be calculated based on the current customer. This is not helpful, because you can't just enter a new record every time you need a new discount.
This is why default values are not good for this purpose. They are static, and they don't update themselves every second, after every change you make to the customer form. The only way to get the value at the moment you need, is to calculate it at the moment you need to -- not when you change customer, but when you are actually about to enter a new record on the order subform or mainform. This is what the BeforeInsert event can do.
Richard Van WagonerOP
@Reply 2 years ago
I thank you for your help Kevin Robertson, but that does not seem to work either. As far as what you have said Kevin Yip can you tell me where and what to put in the code in before insert event?
Richard Van WagonerOP
@Reply 2 years ago
When I open the subform by itself without the parent form I get a #Name? error in the discount field does this mean anything?
Richard Van WagonerOP
@Reply 2 years ago
Richard Van WagonerOP
@Reply 2 years ago
I just got it fixed. I deleted the subform and started over now it works. Thanks to all.
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Access Expert 9.