d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Need Microsoft Access Maths Help
12Next
Add Reply New Topic New Poll
Member
Posts: 14,067
Joined: Oct 8 2005
Gold: 352.12
Nov 29 2013 03:48pm
Hi guys, not sure if this is the correct place or not but i need some help with the following. Its a bit hard to explain but i will try. I want to be able to apply this sum in a form.


Basically this is the data that will be inside a table.
Country | 1st 0.50 kg | Each additional 0.50kg up to 15kg | Each additional 0.50kg up to 25.00kg | Each additional 0.50kg more than 25.00kg |

Germany | £10.00 | £2.00 | £1.50 | £1.00 |



I will then have a form on the front page with these options.


Destination - Drop down box that is linked to the country field
Weight - Weight.
Total - Calculation


I will then want it to work out the calculation for the user. This is an example.


E.G 1: Total Weight = 8KG. This is £10.00 for the first 0.50 and then each 0.50KG up to the total weight at. 15x £2.00 + £10.00 = £40.

E.G 2: Total Weight = 15KG . This is different. This is £10.00 for the first 0.5 and then its the £1.50 for each additional as its over the first bracket it then just takes it from the second and skips the first. so this would be: £1.50 x 15 + £22.50 + £10 = £32.50


I will obviously have a different price for every country in the world and every country listed

Looking for help on this please :)



Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Nov 29 2013 04:03pm
what part of that do you need help with?

This post was edited by carteblanche on Nov 29 2013 04:03pm
Member
Posts: 14,067
Joined: Oct 8 2005
Gold: 352.12
Nov 29 2013 04:12pm
How i would set something like that up. like the calculations and the forms. Im literally learning Access as i go along. its very hard
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Nov 29 2013 04:20pm
Quote (demonblade05 @ Nov 29 2013 05:12pm)
How i would set something like that up. like the calculations and the forms. Im literally learning Access as i go along. its very hard


i'm not familiar with what you mean by "forms". does access come with the framework for it, or are you using something else for the front end (eg: vb, c#, java, php, etc)? i assume you dont have to write the logic and build the message via sql, and you just need to fetch the data in sql.

Member
Posts: 14,067
Joined: Oct 8 2005
Gold: 352.12
Nov 29 2013 04:23pm
By Forms its like the front end. But yes i can't get my head around the logic. It needs to be something like'

If under 15kg use column X. if under 25 use column X. if over 25 use column X

Then the sum will come in once it will grab the correct set of data

This post was edited by demonblade05 on Nov 29 2013 04:24pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Nov 29 2013 04:37pm
Quote (demonblade05 @ Nov 29 2013 05:23pm)
By Forms its like the front end. But yes i can't get my head around the logic. It needs to be something like'

If under 15kg use column X.  if under 25 use column X. if over 25 use column X

Then the sum will come in once it will grab the correct set of data


if those column headers are all hard-coded and do not vary by country, then just hard code the strings, then conditionally add them in based on the weight

Code

select UPTO_.5KG, UPTO_15KG, UPTO_25KG, OVER25KG from prices where country = 'GERMANY';

string1 = "This is £{UPTO_.5KG} for the first 0.50"
string2 = "and then {UPTO_15KG} for up to 15kg"
string3 = "and then {UPTO_25KG} for up to 25kg"
string4 = "and then {OVER_25KG} for the rest"

updatedweight = weight - .5;

messagestart = string1;
messageend = "that is {UPTO_.5KG}";
if {weight} >= .5
messagestart += string2;
messageend += " + {UPTO_15KG}*" + min(15, updatedweight);
updatedweight -= 15;
if {weight} >= 15kg
messagestart += string3;
messageend += " + {UPTO_25KG}*" + min(25, updatedweight);
.... etc

showmessage(messagestart + messageend);

Member
Posts: 14,067
Joined: Oct 8 2005
Gold: 352.12
Nov 29 2013 04:47pm
the columns all stay the same. How does the calculation work for bringing out the costs with the times?
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Nov 29 2013 04:48pm
Quote (demonblade05 @ Nov 29 2013 05:47pm)
the columns all stay the same. How does the calculation work for bringing out the costs with the times?


not sure what you're asking. are you talking about messageend in my code?
Member
Posts: 14,067
Joined: Oct 8 2005
Gold: 352.12
Nov 29 2013 05:10pm
Quote (carteblanche @ Nov 29 2013 10:48pm)
not sure what you're asking. are you talking about messageend in my code?


Well what did you mean by hard coded ?
Member
Posts: 14,067
Joined: Oct 8 2005
Gold: 352.12
Nov 30 2013 01:32pm
Still needing help please
Go Back To Programming & Development Topic List
12Next
Add Reply New Topic New Poll