I DO NOT want the record to save

  • Thread starter ipower2 via AccessMonster.com
  • Start date
I

ipower2 via AccessMonster.com

I have a fee calculator. Each time I open the database I enter a date and it
calculates a fee based on the date and the time that the item has been in
storage. There is no reason to store this information because each time it
will be different. I had this working for me at one point, however a
harddrive crash has made me have to make this db again. Also I am having
probelms with calculation dollar amounts. It is giving me weird dollar
amounts that are off by 1 or 2 cents. Any help will be appreciated.

All the fields are of type: DOUBLE

these are my calculations

days stored = todaysdate-datestored
tow fee=45
storage fee = days stored* 10
tax=storage fee * 0.825
total storage fee=storage fee+tax+tow fee

sometimes if there is the need there is another fee added which is the
notification fee. I add this fee if there is a notification letter sent. If
the letter is sent, there is a check mark that indicates to add the fee.

Once again any help will be appreciated..

Thanks,
Ivan
 
J

John W. Vinson

I have a fee calculator. Each time I open the database I enter a date and it
calculates a fee based on the date and the time that the item has been in
storage. There is no reason to store this information because each time it
will be different. I had this working for me at one point, however a
harddrive crash has made me have to make this db again. Also I am having
probelms with calculation dollar amounts. It is giving me weird dollar
amounts that are off by 1 or 2 cents. Any help will be appreciated.

All the fields are of type: DOUBLE

That's a problem right there. Doubles are floating point numbers with about 14
decimals of precision; even if you're only displaying two decimals, the
calculations will be done out in the hidden digits, giving possibly strange
roundoff errors. Don't use ANY Number subtype; instead use a Currency field,
which has exactly four decimals with no roundoff error.

If you don't want to store the data, don't store the data. Just use unbound
textboxes on your forms with the expressions as the control source. Examples
below:

these are my calculations

days stored = todaysdate-datestored

=DateDiff("d", [DateStored], Date())
tow fee=45

Set the Default Value property of the textbox to 45.
storage fee = days stored* 10

=CCur([Days Stored] * 10)
tax=storage fee * 0.825

= Round([Storage fee] * 0.825, 2)

That assumes that the tax rate is 82.5% which sounds rather exorbitant to me!
Are you sure you don't mean 0.0825?
total storage fee=storage fee+tax+tow fee

=NZ([Storage Fee]) + NZ([Tax] + NZ([Tow fee])
sometimes if there is the need there is another fee added which is the
notification fee. I add this fee if there is a notification letter sent. If
the letter is sent, there is a check mark that indicates to add the fee.


Just add

+ IIF([LetterSent], 12.5, 0)

assuming the notification fee is $12.50.
 
I

ipower2 via AccessMonster.com

Thank you for your reply John.

I was able to keep the numbers from being stored by making the text fields
unbound text boxes.

I also was able to overcome my math problem by chance by using the format
function. The following is the code which I used.

Me.daysimpounded = DateDiff("d", [DateImpounded], Date) + 1
The reason there is a one added is because there is still an impound fee for
one day when the vehicle is impounded and picked up on the same day.

If Me.Notification = -1 Then (check box that tells whether there is a
notification letter sent is marked or not)

Me.Storagefee = CCur([daysimpounded] * 10)
Me.Tax = [Storagefee] * 0.0825

Me.Text18 = Format(Me.TowFee + Me.Storagefee + Me.Tax + Me.Notificationfee,
"####.##") (Without the format function, the dollar amounts is still off by 1
cent. After the format is forced to ####.##, the dollar amount is properly
calculated. )

Else
Me.Storagefee = CCur([daysimpounded] * 10)
Me.Tax = [Storagefee] * 0.0825
Me.Text18 = Format(Me.TowFee + Me.Storagefee + Me.Tax, "####.##")
End If

I have a fee calculator. Each time I open the database I enter a date and it
calculates a fee based on the date and the time that the item has been in
[quoted text clipped - 5 lines]
All the fields are of type: DOUBLE

That's a problem right there. Doubles are floating point numbers with about 14
decimals of precision; even if you're only displaying two decimals, the
calculations will be done out in the hidden digits, giving possibly strange
roundoff errors. Don't use ANY Number subtype; instead use a Currency field,
which has exactly four decimals with no roundoff error.

If you don't want to store the data, don't store the data. Just use unbound
textboxes on your forms with the expressions as the control source. Examples
below:
these are my calculations

days stored = todaysdate-datestored

=DateDiff("d", [DateStored], Date())
tow fee=45

Set the Default Value property of the textbox to 45.
storage fee = days stored* 10

=CCur([Days Stored] * 10)
tax=storage fee * 0.825

= Round([Storage fee] * 0.825, 2)

That assumes that the tax rate is 82.5% which sounds rather exorbitant to me!
Are you sure you don't mean 0.0825?
total storage fee=storage fee+tax+tow fee

=NZ([Storage Fee]) + NZ([Tax] + NZ([Tow fee])
sometimes if there is the need there is another fee added which is the
notification fee. I add this fee if there is a notification letter sent. If
the letter is sent, there is a check mark that indicates to add the fee.

Just add

+ IIF([LetterSent], 12.5, 0)

assuming the notification fee is $12.50.
Once again any help will be appreciated..

Thanks,
Ivan
 
J

John W. Vinson/MVP

Thank you for your reply John.

I was able to keep the numbers from being stored by making the text fields
unbound text boxes.

I also was able to overcome my math problem by chance by using the format
function. The following is the code which I used.

Me.daysimpounded = DateDiff("d", [DateImpounded], Date) + 1
The reason there is a one added is because there is still an impound fee for
one day when the vehicle is impounded and picked up on the same day.

If Me.Notification = -1 Then (check box that tells whether there is a
notification letter sent is marked or not)

Me.Storagefee = CCur([daysimpounded] * 10)
Me.Tax = [Storagefee] * 0.0825

Me.Text18 = Format(Me.TowFee + Me.Storagefee + Me.Tax + Me.Notificationfee,
"####.##") (Without the format function, the dollar amounts is still off by 1
cent. After the format is forced to ####.##, the dollar amount is properly
calculated. )

Else
Me.Storagefee = CCur([daysimpounded] * 10)
Me.Tax = [Storagefee] * 0.0825
Me.Text18 = Format(Me.TowFee + Me.Storagefee + Me.Tax, "####.##")
End If

A Currency value has four decimals, no matter how many are displayed.
Using Format() will convert the Currency value to a text string
(rounded as a side effect); you can also use the Round() function:

Me.Tax = Round([storagefee] * 0.0825, 2)

Your Text18 value will be NULL if any one of the components is NULL -
you might need to use the NZ() function to convert nulls to zero, e.g.

Me.Text18 = Format(Nz(Me.TowFee) + Nz(Me.Storagefee) + Nz(Me.Tax),
"####.##")
 
Top