Rounding of numbers?

it sounds like you have put the code name in the properties sheet instead of calling from the module. Property sheet should be showing [Event Proceedure]

Peter
 
Bat17 said:
it sounds like you have put the code name in the properties sheet instead of calling from the module. Property sheet should be showing [Event Proceedure]

Peter
That's correct. I have placed it in that field. I thought that was supposed to be done that way. Well, at least... I read that somewhere with a referral to the Round() function. So... that's why I did it.

To do it correctly it would become:

Code:
Private Sub PricePerOneBTWAmount_AfterUpdate()
    
    Round2CB ([PricePerOneBTWAmount, 2])
    
End Sub
or... not? Well... I guess I'll find out soon enough ;-)
 
It's not about the storage size of the data but ensuring the integrity of the data as for the rounding functions supplied by Access, they're crap, don't bother with them.
 
Rich said:
It's not about the storage size of the data but ensuring the integrity of the data as for the rounding functions supplied by Access, they're crap, don't bother with them.
Whahahaha... ok. So it's not just me... :-)

And for the integrity issue.... by storing it, am I endangering the data in the fields? Or am I totally wrong and should I just forget it?

Ehm... a really stupid question maybe... but I can't get the code to work I think...
I've made a seperate module called Round2CB with your code in it. And saved and compiled etc. As far as I know and understand from your function formatting should be done like Round2CB (xxxx, amountofdecimals)
When I place that code in the after update event procedure I get the following error:
Microsoft Visual Basic
Compile error:
Expected variable or procedure, not module
OK Help

The help says:
There is no variable or procedure by this name in the current scope, but there is a module by this name. This error has the following cause and solution:

The name of a module is used as a variable or procedure.
Check the spelling of the variable or procedure name, and make sure the name you want to refer to isn't private to another module. A module name can be a qualifier, but can't stand alone.

And.... I don't understand... Do I need to place your code somewhere in the form code than? Or.....?

When I used the GetOpenFileName function from the mvps.org page and the TimeDiff function too... I did work in the same manner. So what's wrong this time?
 
Last edited:
I notice that you say your module name is Round2CB but that is the Function name and they cannot be the same, change your module name to say Roundingfunctions and try again.

Brian
 
Thanks!

That took care of that error, but now there is a new one when using:

Code:
Private Sub PricePerOneExBTW_AfterUpdate()
    Round2CB ([PricePerOneExBTW, 2])
End Sub
Run time error 2465

CCS can't find the field | referred to in your expression. When I click debug it points to the Round2CB line. When I click help, the help window stays empty.

On the web I've some info but it doesn't seem to apply to this. Mostly references to fields that could not be found, but why would a field not be able to find itself AND refer to itself as | ?

I've tried (xxxx, [decimals]) too, but that also won't work.
 
I think that should be

Code:
Private Sub PricePerOneExBTW_AfterUpdate()
  me.PricePerOneExBTW = Round2CB(me.[PricePerOneExBTW, 2])
End Sub

Brian
 
me.PricePerOneExBTW = Round2CB(me.[PricePerOneExBTW, 2])

should be

me.PricePerOneExBTW = Round2CB(me.[PricePerOneExBTW], 2)

this should change any value typed into PricePerOneExBTW into a 2 decimal number

Peter
 
Since by default the function will just return two decimal places there's no need to put the 2 in. In any case you only need the Function when summing the field something like =Sum(Round2CB([ItemCost])
 
Bat17 said:
me.PricePerOneExBTW = Round2CB(me.[PricePerOneExBTW, 2])

should be

me.PricePerOneExBTW = Round2CB(me.[PricePerOneExBTW], 2)

this should change any value typed into PricePerOneExBTW into a 2 decimal number

Peter

Sorry, copied the error from the original:o

Brian
 
Ah yes! That does the trick. Phiew... thank you guys, very much.
 

Users who are viewing this thread

Back
Top Bottom