Solved How to make changable default value by formula? (1 Viewer)

yunhsuan

Member
Local time
Tomorrow, 06:54
Joined
Sep 10, 2021
Messages
54
Hello
I'm trying to make a accounting system by access. There would be quantity, unit price and taxes. Generally, taxes is calculated by quantity * unit price * 5%. I set formula for automatic calculation. Somtimes, taxes is not 5% of price, but the value of taxes cannot be changed. How can I set a changable default value by formula?

Thanks for every suggestion!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:54
Joined
Oct 29, 2018
Messages
21,469
You should be able to use an expression. For example, if you store the changeable default value in a table, you can use a DLookup() expression as a default value.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 17:54
Joined
Feb 28, 2001
Messages
27,179
Somtimes, taxes is not 5% of price, but the value of taxes cannot be changed.

The trick is to have a way to know when the tax is not 5%. Can you give us an example of a time when the tax is not 5% and how you would compute it by hand? If taxes are normal, you do price * quantity * 5% - but what do you do when it isn't 5%? That way, we can see what might be the best or easiest way to do this. Include in your discussion that you explain HOW you know that for the sample you offer that you know the tax will NOT be 5%. The way to know that is crucial to the question. (It makes the difference between a lookup vs. a simple formula.)
 

yunhsuan

Member
Local time
Tomorrow, 06:54
Joined
Sep 10, 2021
Messages
54
The trick is to have a way to know when the tax is not 5%. Can you give us an example of a time when the tax is not 5% and how you would compute it by hand? If taxes are normal, you do price * quantity * 5% - but what do you do when it isn't 5%? That way, we can see what might be the best or easiest way to do this. Include in your discussion that you explain HOW you know that for the sample you offer that you know the tax will NOT be 5%. The way to know that is crucial to the question. (It makes the difference between a lookup vs. a simple formula.)
Generally, taxes are 5% in invoice and 0 in other duty-free receipt.
But, 5% could be changed incidentally in invoice. This is unpredictable.

In my table, there are receipt field(invoice or duty-free receipt), quantity field, unit price field and taxes field.
I hope the taxes field could be automatically calculated, and its result could be changed manually.
Please give me some good advice!
 
Last edited:

yunhsuan

Member
Local time
Tomorrow, 06:54
Joined
Sep 10, 2021
Messages
54
You should be able to use an expression. For example, if you store the changeable default value in a table, you can use a DLookup() expression as a default value.
I hope the result of calculation could be changed manually.
Can DLookup() expression do this?
If it could, can you tell me how to use DLookup() to achieve my purpose?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:54
Joined
Oct 29, 2018
Messages
21,469
I hope the result of calculation could be changed manually.
Can DLookup() expression do this?
If it could, can you tell me how to use DLookup() to achieve my purpose?
Hi. You started out asking about the default value, and that's what I was addressing. But now, you seem to be talking about modifying the result of an expression. Those are two different things.

If you have an expression like 2+2, the result would be 4, and you won't be able to modify it to 6, for example. However, default value is just a convenience feature for new records. If you assign the number 4 as the default value, new records will automatically get a 4. However, you can change it to 6 or 0 if you don't want to keep the 4.

Hope that gives you some ideas.
 

yunhsuan

Member
Local time
Tomorrow, 06:54
Joined
Sep 10, 2021
Messages
54
Hi. You started out asking about the default value, and that's what I was addressing. But now, you seem to be talking about modifying the result of an expression. Those are two different things.

If you have an expression like 2+2, the result would be 4, and you won't be able to modify it to 6, for example. However, default value is just a convenience feature for new records. If you assign the number 4 as the default value, new records will automatically get a 4. However, you can change it to 6 or 0 if you don't want to keep the 4.

Hope that gives you some ideas.
Thanks for your reply!
I finally success!!!
 

yunhsuan

Member
Local time
Tomorrow, 06:54
Joined
Sep 10, 2021
Messages
54
Good luck with your project.
I meet problem soon...
The taxes value would not change according to quantity and unit price in the second record.
Do I use the wrong method?
Below is my test file. Could you tell me how to edit it??
 

Attachments

  • Database4.accdb
    628 KB · Views: 211

Users who are viewing this thread

Top Bottom