Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / September 2007

Tip: Looking for answers? Try searching our database.

Round off a Number Field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Phil - 17 Sep 2007 16:56 GMT
Hi,
I have a form where I input numbers.  If the number inputed is greater that
99.99 I want to found off to the nearest whole number.  What would the code
be for doing this and in which event should I place the code?  I've tried
various things, none of which worked.

Thanks
Signature

Phil

John W. Vinson - 17 Sep 2007 18:17 GMT
>Hi,
>I have a form where I input numbers.  If the number inputed is greater that
[quoted text clipped - 3 lines]
>
>Thanks

You can use the AfterUpdate event of the textbox in which you're entering the
number (confusingly enough, the BeforeUpdate event doesn't work but
AfterUpdate does):

Private Sub txtMyTextbox_AfterUpdate()
If Me!txtMyTextbox > 99.99 Then
  Me!txtMyTextbox = Round(Me!txtMyTextbox, 0)
End If
End Sub

            John W. Vinson [MVP]
Maurice - 17 Sep 2007 18:22 GMT
Maybe it is better to place that in your query if that's the recordsource.
You could use something like:

iif([number]>99.99;cint(number);number)

cint will make the number a whole number.
Signature

Maurice Ausum

> Hi,
> I have a form where I input numbers.  If the number inputed is greater that
[quoted text clipped - 3 lines]
>
> Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.