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!

Error 3759 Scaling of decimal value resuled in data truncation

Status
Not open for further replies.

precious5

Programmer
Aug 22, 2001
13
US
Has anyone ran across this error when tring to import data from a text file to an Access 2000 database?? I've doubled checked my length of the field to make sure I'm getting the correct amount of characters and also the starting position.

RunTime Error 3759:
Scaling of decimal value resuled in data truncation

I'm using the mid function to retrieve the data. Here's a sample of the code:

rs1!ActualKW = Mid(s, 121, 13)

Any help would be greatly appreciated. Thanks in advance.

Lori
 
Can you post the value you are trying to put into your database? What datatype of field are you trying to put it into?
 
I'm putting it into a number field. The value changes depending on the record. After putting it in debug, I'm reading the first 3 records fine then it crashes on this record. The value it's reading is 000000075.60 but like I said this value changes with each record. If I remove the record then it reads the next couple of records fine and crashes again on the same field. I have put the text file in a text editor and also a hex editor to see if I could see anything funny with those records, but I don't see anything. They look like the previous records it read just fine.
 
Have you tried stuffing it into a Double variable?
Are all the fields always exactly the same length?
Is the value 000000075.60 what you read from the line with your Mid$ call?
I assume your database field is a Real ...
 
The fields are ALWAYS the same length. The program crashes on that statement, so I can't see what is in the field. I have to look at the fields previously moved. I haven't tried the double. I have it as a decimal, which should be large enough to hold the values.

I don't understand what you mean by:

"I assume your database field is a Real ..."

Thanks,

Lori
 
Real/Decimal/Single/Double/etc.

Maybe try CDbl(Mid(s, 121, 13)) which should convert it into a double, hence losing leading zeros. You might want to seperate them into individual lines to assist debugging.
e.g.
Dim NumStr As String
Dim NumVal As Double
NumStr = Mid(s, 121, 13)
NumVal = CDbl(NumStr)
rs1!ActualKW = NumVal
 
Using the decimal it does strip out the leading zeros in the previous reads
 
Which line does the error occur on?
If it's the "rs1!ActualKW =" line, have you tried reassigning the NumVal variable in the Immediate window?

i.e. When you hit the error, go into the Immediate window and type NumVal = 75.6 then try to continue execution - does it still fail?

If not, we will have to look elsewhere - can you provide more information (BTW, going home in 20 mins)
 
I think I know why its failing. The previous records have .00. For some reason it doesn't like anything after the decimal point. Any ideas why?
 
Norris68,
Thanks for your help yesterday. Once I changed the data type in the database it worked. I still don't understand why the decimal data type would not work and the double did. But thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top