Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rounding Problem in a form.

Status
Not open for further replies.

DJKAOS

Technical User
Jun 30, 2000
101
US
I have a form based on a Query (the query calculates all of its numbers by calling some VB functions.)

anyway on my form I set the Format = Fixed and Decimal = 0
so that It would round off but it doesnt work...it still shows all the decimal values. Also the drop down list for Format in the properties is blank unless I delete whats in the control source field.

What the heck is going on? it worked for my on every other form..I can't figure out what the problem is.

 
Maybe a dumb question, but is the query returning a string or number for the field you are having a problem with? If it is returning a string, the format on the form would be ignored. dz
 
Its returning a Variant. but actually all the values are Doubles, and Null's

Should I have it return something other than a variant?
 
Well, that *could* be the problem. If you return a variant and the data is a string, the format won't work. If you return a variant and the data is a number, the format should work. Is the data that you are having trouble with the result of a VB function? If so, maybe you can post a specific example. You might try to make sure that the query retursn numbers. If it doesn't correct the problem, you can always put it back the way it was and look for another solution. dz
 
I tried changing it to return a double instead. (that messes up all my code though a bit because all the nulls have to be 0's or it crashes.).

Anyway having it return a double worked.

Yes the problem is from VB functions... I Think I have an idea how to fix it but it will be a real pain in the #@$@#..but I think it will work.
 
Well, if it worked when you return a Double, then you know that was the problem. Will the Nz function solve your nulls have to be 0s problem? Maybe you can put the Nz function around your fields so they return 0 if they are null. dz
 
I have the Nz()'s in there..its hard for me to explain.

Is there some way I can Convert the value to a double before it gets loaded into the form?
 
You might try the CDbl() function. I don't understand why you have to return Variants, but CDbl() might work. dz
 
Because when I calculate averages I dont want fields with 0's in them to be included in the average..therefore I make them Null and the built in average function ignores null values.

Thanks I'll try that.

Is there any way to set a a double value to null?
like
Dim Variable As Double
Variable = Null 'doesn't work but I need a way for it to work.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top