[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Can I force a calculation to round up to a whole number

Posted on 2006-04-08
7
Medium Priority
?
519 Views
Last Modified: 2006-11-18
Hi Experts,

I have a text box called (totbat)that has the following calculation in it's control source =([tilepitchmult1]/100)
tilepitchmult1 is another text box that has a value that always changes based on the value the user enters, Lets say tilepitchmult1 has a value of 88 in it, (totbat) will display .88 using the calculation =([tilepitchmult1]/100)

Can I force it to round up to a (1) a whole number?

If so can you describe how?

Thanks--I'll greatly appreciate any help!!

patentinv
0
Comment
Question by:patentinv
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 39

Accepted Solution

by:
thenelson earned 668 total points
ID: 16409469
=Round(([tilepitchmult1]/100) + 0.49)
0
 
LVL 44

Assisted Solution

by:Arthur_Wood
Arthur_Wood earned 668 total points
ID: 16409470
Use the cInt function

cInt(.88) = 1

using the calculation = cInt([tilepitchmult1]/100)

AW
0
 
LVL 58

Assisted Solution

by:harfang
harfang earned 664 total points
ID: 16409474
Hi,

To round to an integer, use CIng() or CDbl(). If you need to specify a number of decimals, use Round(). In your case, I'd suggest:

    =CInt([tilepitchmult1]/100)

Cheers!
(°v°)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:patentinv
ID: 16409536
I've been trying to figure this out for a couple of hours and within 5-10 minutes after posting my question, you experts once again give me the answer.

All the your responses worked just as I was wanting it to.

Thanks thenelson, Arthur_Wood/AW and harfang.

patentinv
0
 

Author Comment

by:patentinv
ID: 16410106
Hi thenelson,

After putting the following responses to work, your response seems to be a better fit in my case, your response rounds all calculations up to the next whole number, which is exactly what I needed, the CInt doesn't round up, so in my case it it will not work.

I Just wanted to thank you once again for your help, I don't know what I would do with out your help and ideas, I really appreciate it.

Oh yea, I don't know if you remember the code you gave me for a question I posted, but to refresh your memory, here's the code once again you gave me,
It copied a form from one .mdb file to another .mdb file when opened.

Private Sub Form_Load()
'Delete the old form.
    Dim objAcc As New Access.Application
   
    objAcc.OpenCurrentDatabase "C:\Documents and Settings\Chuck\Desktop\est.mdb"
    objAcc.DoCmd.DeleteObject acForm, "Contractprop"
    objAcc.CloseCurrentDatabase
    objAcc.Quit
   
    Set objAcc = Nothing

'Copy the new form.
DoCmd.CopyObject "C:\Documents and Settings\Chuck\Desktop\est.mdb", "Contractprop", acForm, "Contractprop"

End Sub

All this was working fine untill I implemented all the security into my .mdb file, most of what you helped me with also, thanks.
But the reason I bring this up is I just wanted to let you know for future use you can use another line of code that will do the same thing but will bypass the login script and KillIt module which only opens the .mdb file in runtime mode.
This is important because if the user updates his .mdb file by adding a form and it requires him to login into the.mdb file and the user that he logins into as must have modify rights in order to update this form with a new one, now all security is shot, and if the user has access installed then the .mdb file will try and open in full access and with the KillIt module implemented it will never even open so this user will not be able to update his form and I will lose out on a sell, so you see why this was a problem, we'll after a week of trying to figure out what to do I posted a question on rent a coder and got a solution, not cheap but it works. here's the line of code, that replaces yours and by passes all security and still copies the form.

DoCmd.TransferDatabase acExport, "Microsoft Access", "C:\3106.mdb", acForm, "Contractprop", "Contractprop", False

Once again thanks for all your help!!!

thanks--patentinv
0
 
LVL 39

Expert Comment

by:thenelson
ID: 16411096
CInt will round up if you add 0.49 to the number first.  I prefer Round as it better explains what I am doing when I come back to the code later.

Thanks for the update.

Glad to help and thank you very much for the points with "A" grade!

Happy Computing!

Nelson
0
 
LVL 58

Expert Comment

by:harfang
ID: 16411211
Thanks for the split. I did overlook the "round up" request, sorry about that.

While I'm at it, consider this slightly more accurate "round up" expression:

    =-Int(-[tilepitchmult1]/100)

Int() rounds *down*: Int(1.9999) = 1, but also Int(-1.0001) = -2. By using two minus signs, -Int(-x) becomes a totally accurate round up function...

Cheers, and thanks again!
(°v°)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question