473,386 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Data Conversion Error - Need Fresh Eyes

133 100+
Hi,

In the following code, i keep getting a data conversion error at the fund field. In the code below, it takes data from a query and creates a table. It is a six digit alpha field within the query and within the created table. it bombs out on this line when writing the field:

Expand|Select|Wrap|Line Numbers
  1.    rstSummary!fund = strTempFund
  2.  
This below is the procedure.

Any guidance would be appreciated.


Expand|Select|Wrap|Line Numbers
  1. Private Sub Create_tbl_IDT_High_Level()
  2.  
  3.    On Error GoTo Err_Hndlr
  4.  
  5. '*****************************************************************************************
  6. ' This sub routine builds a table
  7. '
  8. '******************************************************************************************
  9.  
  10. strFirstRec = "Yes"
  11.  
  12. ' **** initialize temporary fields, date is set to dummy initial date, it has no meaning
  13.  
  14.  
  15. strTempSeqNumber = 0
  16. strTempIndexOrg = 0
  17. strTempFund = " "
  18. strTempAccountCode = 0
  19. strTempTotalPrice = 0
  20. strTempInd = " "
  21. strTempRuleCode = " "
  22. strTempSalesOrder = " "
  23. strTemp_d_AccumativePrice = 0
  24. strTemp_c_AccumativePrice = 0
  25. Dim tbl_IDT As DAO.TableDef
  26. Dim idxSeqNumber As DAO.Index
  27.  
  28.  
  29.  
  30. '**** create output table
  31. 'Delete temporary table
  32. DoCmd.RunSQL "DROP TABLE tbl_IDT_High_Level;"
  33.  
  34. 'Create temporary table
  35. CurrentDb.Execute ("CREATE TABLE tbl_IDT_High_Level(SeqNumber smallint, IndexOrg Integer, " & _
  36.                                         "Fund VARCHAR(6), " & _
  37.                                         "AccountCode Integer, " & _
  38.                                         "TotalPrice money, " & _
  39.                                         "Ind VARCHAR(1), " & _
  40.                                         "RuleCode VARCHAR(4),  " & _
  41.                                         "SalesOrder VARCHAR(8))")
  42.  
  43.  
  44. ' DoCmd.RunSQL "CREATE INDEX idxSeqNumber ON tbl_IDT (SeqNumber) WITH PRIMARY"
  45.  
  46.  
  47. 'Bind rstTemp to the temporary table
  48. Set rstTemp = CurrentDb.OpenRecordset("sql_IDT_RPT_Step03_Format")
  49. Set rstSummary = CurrentDb.OpenRecordset("tbl_IDT_High_Level")
  50.  
  51.  
  52. rstTemp.MoveFirst
  53.  
  54. Do While rstTemp.EOF = False
  55.  
  56.  
  57.  
  58.     ' ***************************************************
  59.     ' first record flag
  60.     ' ***************************************************
  61.  
  62.     If strFirstRec = "Yes" Then
  63.         strFirstRec = "No"
  64.     End If
  65.         strTempSeqNumber = strTempSeqNumber + 1
  66.  
  67.         strTempIndexOrg = rstTemp!IndexOrg
  68.         strTempFund = rstTemp!fund
  69.         strTempAccountCode = rstTemp!AccountCode
  70.         strTempTotalPrice = rstTemp!TotalPrice
  71.         strTempInd = rstTemp!Ind
  72.         strTempRuleCode = rstTemp!RuleCode
  73.         strTempSalesOrder = rstTemp!SalesOrder
  74.  
  75.  
  76.  
  77.         rstSummary.AddNew
  78.             rstSummary!SeqNumber = strTempSeqNumber
  79.             rstSummary!IndexOrg = strTempIndexOrg
  80.             rstSummary!fund = strTempFund
  81.             rstSummary!AccountCode = strTempAccountCode
  82.             rstSummary!TotalPrice = strTempTotalPrice
  83.             rstSummary!Ind = strTempInd
  84.             rstSummary!RuleCode = strTempRuleCode
  85.             rstSummary!SalesOrder = strTempSalesOrder
  86.         rstSummary.UPDATE
  87.  
  88.         ' Get Accummulative Totals
  89.         If strTempInd = "D" Then
  90.             strTemp_d_AccumativePrice = strTemp_d_AccumativePrice + strTempTotalPrice
  91.         Else
  92.             strTemp_c_AccumativePrice = strTemp_c_AccumativePrice + strTempTotalPrice
  93.         End If
  94.  
  95.             Debug.Print "Start******************: ";
  96.             Debug.Print pvbNewLine
  97.             Debug.Print "strTemp_D_AccumativePrice: "; strTemp_d_AccumativePrice;
  98.             Debug.Print pvbNewLine
  99.             Debug.Print "strTemp_c_AccumativePrice: "; strTemp_c_AccumativePrice;
  100.             Debug.Print "end******************: ";
  101.             Debug.Print pvbNewLine
  102.  
  103.         strTempIndexOrg = 0
  104.         strTempFund = " "
  105.         strTempAccountCode = 0
  106.         strTempTotalPrice = 0
  107.         strTempInd = " "
  108.         strTempRuleCode = " "
  109.         strTempSalesOrder = " "
  110.  
  111.     rstTemp.MoveNext
  112. Loop
  113.  
  114. '***        write accumative recordst record
  115.         If strTemp_d_AccumativePrice > 0 Then
  116.             strTempSeqNumber = strTempSeqNumber + 1
  117.             strTempIndexOrg = Null
  118.             strTempFund = "UK0000"
  119.             strTempAccountCode = 111101
  120.             strTempTotalPrice = strTemp_d_AccumativePrice
  121.             strTempInd = "C"
  122.             strTempRuleCode = "J099"
  123.  
  124.             rstSummary.AddNew
  125.                 rstSummary!SeqNumber = strTempSeqNumber
  126.                 rstSummary!IndexOrg = strTempIndexOrg
  127.                 rstSummary!fund = strTempFund
  128.                 rstSummary!AccountCode = strTempAccountCode
  129.                 rstSummary!TotalPrice = strTempTotalPrice
  130.                 rstSummary!Ind = strTempInd
  131.                 rstSummary!RuleCode = strTempRuleCode
  132.                 rstSummary!SalesOrder = strTempSalesOrder
  133.             rstSummary.UPDATE
  134.         End If
  135.  
  136.         If strTemp_c_AccumativePrice > 0 Then
  137.             strTempSeqNumber = strTempSeqNumber + 1
  138.             strTempIndexOrg = " "
  139.             strTempFund = "UK0000"
  140.             strTempAccountCode = 111101
  141.             strTempTotalPrice = strTemp_c_AccumativePrice
  142.             strTempInd = "D"
  143.             strTempRuleCode = "J099"
  144.  
  145.             rstSummary.AddNew
  146.                 rstSummary!SeqNumber = strTempSeqNumber
  147.                 rstSummary!IndexOrg = strTempIndexOrg
  148.                 rstSummary!fund = strTempFund
  149.                 rstSummary!AccountCode = strTempAccountCode
  150.                 rstSummary!TotalPrice = strTempTotalPrice
  151.                 rstSummary!Ind = strTempInd
  152.                 rstSummary!RuleCode = strTempRuleCode
  153.                 rstSummary!SalesOrder = strTempSalesOrder
  154.             rstSummary.UPDATE
  155.         End If
  156.  
  157. rstTemp.Close
  158. rstSummary.Close
  159. Create_tbl_IDT_High_Level_Exit:
  160.   Exit Sub
  161.  
  162.  
  163. Err_Hndlr:
  164.  
  165.  
  166.     MsgBox "[" & Err.Number & "]:  " & Err.Description, vbInformation, "Create_tbl_IDT_High_Level()"
  167. End Sub
  168.  
Feb 15 '11 #1

✓ answered by ADezii

I'm a little confused since you state that rstTemp is Bound to the Temporary Table, but isn't rstSummary?
Expand|Select|Wrap|Line Numbers
  1. 'Bind rstTemp to the temporary table 
  2. Set rstTemp = CurrentDb.OpenRecordset("sql_IDT_RPT_Step03_Format") 
  3. Set rstSummary = CurrentDb.OpenRecordset("tbl_IDT_High_Level") 
What is the definition of:
Expand|Select|Wrap|Line Numbers
  1. sql_IDT_RPT_Step03_Format

2 2058
ADezii
8,834 Expert 8TB
I'm a little confused since you state that rstTemp is Bound to the Temporary Table, but isn't rstSummary?
Expand|Select|Wrap|Line Numbers
  1. 'Bind rstTemp to the temporary table 
  2. Set rstTemp = CurrentDb.OpenRecordset("sql_IDT_RPT_Step03_Format") 
  3. Set rstSummary = CurrentDb.OpenRecordset("tbl_IDT_High_Level") 
What is the definition of:
Expand|Select|Wrap|Line Numbers
  1. sql_IDT_RPT_Step03_Format
Feb 16 '11 #2
dowlingm815
133 100+
Good morning,

rstTemp isn't a temp table, i forgot to delete that comment. Hot dog, :D, got it thank you...fund was converted to binary.
Feb 16 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: New MSSQL DBA | last post by:
Hi all, we are now planning to upgrade our application from a non-unicode version to a unicode version. The application's backend is a SQL Server 2000 SP3. The concern is, existing business...
1
by: Balaji Neelakantan Pooruli | last post by:
Hi, We were in need of altering a DB2 table in which one of the column has been changed from VARCHAR(256) to INTEGER. I have extracted the table data into a tape before alters. After the alters...
1
by: Tu Quach | last post by:
I got error message like "run time error 3421: data type conversion error" how can i fix the trouble like that, any references should i include in ? any help would be great thank you
2
by: al | last post by:
Dim dbParam_amount As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter dbParam_amount.ParameterName = "@amount" dbParam_amount.Value = amount.text dbParam_amount.DbType =...
6
by: Ecohouse | last post by:
I have a field in a recordset which is a string. It can look like this: 13-15-67-56 I need to break out this string into numbers to run in queries to open recordsets. But when I try to open...
2
by: Reggie | last post by:
Hi and TIA. I have a dataset that I fill from an Access table. Some integer and date fields are null. I'm iterating through the records and sending them to an SQL database table. The problem...
4
by: SAL | last post by:
I'm sorry if this has been answered before but I didn't see it in a quick scan of the list. The following code is causing an error when the field is null: Error text: Conversion from type...
7
by: girl | last post by:
Hi i have a problem with MS SQL server 2000 and hope to seek for some advise. i have the following samples aa|0|abcdefg| b|0|abcdefg| i used the bulk insert in the query analyser.. BULK...
1
by: Javilen | last post by:
Hello, edit: added some more info I am trying to set up a job to run a SSIS package in SQL 2005, the SQL 2005 is installed on a Windows server 2003 machine. start Edit I have the...
4
by: shalskedar | last post by:
I want to transfer the excel data to th Db ..thru the VBA code. In the DB there is a table called outer2 containing 1 of the columns as "Upvc" whose format is set to Long integer. When i try to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.