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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can't hold format for number

Status
Not open for further replies.

Judi201

Technical User
Jul 2, 2005
315
US
Hi!

Here I am back with a simple issue that I can't track down.

I am updating a field in a view that is the difference in two other fields in a different table. All fields are N 10 with 2 decimals. This is done to display in a grid. The amount is shown without decimals even tho the grid shows 0.00 before the update.

I have checked or tried:

(1)Table structure
(2)format property of the field in the grid
(3)inputmask
(4) round as ROUND((Amt1 - Amt2),2)

Can anyone think of something else that would cause my number to drop the decimals?

Thanks for any suggestions.

Also, the value as it appears in the table when browsed does not have the decimals. So it is not only displayed wrong, it is wrong.

Thanks

Judi
 
Judi,

In your views Select statement you could try something like the following
Code:
SELECT Field1 - Field2 + 00000.00 AS CalcField
to get the decimals included in the output.

Regards,
Jim
 
Jim,

Thanks for your response.

Actually, the value comes in the view correct. In the InteractiveChange of a checkbox in a column in a grid I have this code. After I set the local variables up like this I can see in the DEBUG. I can't see what happens to the amtpaid! I have removed all formatting, including Input Mask, from the textbox of the column.

Code:
LOCAL lnAmtDue, llnDiscRate, lnDiscAmt, lnAmtPaid
lnAmtDue = amtdue							&& shows 11136.79
lnDiscRate = discrate						&& shows 0.0000
lnDiscAmt = ROUND((amtdue * discrate),2)	&& shows 0.00
lnAmtPaid = ROUND((lnAmtdue - lndiscAmt),2) && shows 11136.79
*
REPLACE lvTicket.discamt WITH lnDiscAmt   && goes fine
REPLACE lvTicket.amtpaid WITH lnAmtPaid   && hangs here with 'numeric overflow - data lost'

I am saying it comes in OK. I set it up in the VIEW DESIGNER as 000000.00 AS amtpaid. I shows in the 'Selected fields' in VIEW DESIGNER as 0.00.

When it appears in the GRID it is 0.00. Then I try to use it and get the overflow represented in DEBUG with ******

ANY help would be appreciated.

Judi
 
Judi,

That is strange. I know Tamar Granor, in her book, "Taming Visual FoxPro's SQL", claims that multiplying 2 fields will result in a field long enough to contain the largest possible value that could be produced - I guess basically she's saying if you have 2 numeric 10,2 fields, the resulting value would have to be long enough to store 9999999.99 * 9999999.99. But, in this case you're doing the multiplication after the query is executed, so that shouldn't have any bearing.

That said, about the only thing I can think of is increasing the size of the Ticket.AmtPaid field and seeing if that helps.

Regards,
Jim
 
Jim,

Thanks for you response. I did the only thing I could think of and started over with that part. I set it up the same way and put an InputMask in the testbox of that column and it works. I sometimes forget the order in which I make changes in attempts to fix a problem and am misled in the results!
So, I don't know what fixed it but it's working and I'm happy.

Thanks again.

Judi
 
Jim,

I am adding this for anyone who looks at this later.
The last problem I had with that column, I could not see ANYTHING in the textbox.

I opened a backup copy of that form in the CLASS BROWSER and was scanning for something totally different but noticed that the column that I had 'hassled with' had a "" in the InputMask.
Opening the form, looking in properties you COULD NOT SEE the ""!! Removing them from the code (I would only do this in a backup copy [smile]) caused the form to work perfectly. So one more thing for beginners like me to look for.

Have a great day everyone!

Judi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top