VB6 1004 Application defined or object defined error.

April 12, 2012 at 00:00:43
Specs: Windows 7
Filling in values in Excel 2010 worksheet from recordset in VB6. Worked fine with Excel 2003 before but now, after filling in some data in the worksheet in Excel 2010, suddenly error occurred with 1004 application defined or object defined error. Can anyone help?

See More: VB6 1004 Application defined or object defined error.

Report •

#1
April 12, 2012 at 06:01:07
We might be able to help if you supplied the code that is failing and telling us the specific line that produces the error.

If you are going to post code in this forum, please click on the following line and read the instructions found via that link.

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.


Report •

#2
April 12, 2012 at 18:14:07
Error doesn't occur from the beginning of the loop. After a while of looping the data, error occurred in line 1820. Here are the codes:

1690                      With rsMold
1700                          If .RecordCount > 0 Then
1710                              .MoveFirst
1720                              While Not .EOF
1730                                  wsTemp.Range(cContentB).Copy Destination:=wsExcel.Range("$" & intCurrLine & ":$" & (intCurrLine))

1740                                  If rsMold("FinalSupp") = rsMold("SUPPCODE") Then
1750                                      wsExcel.Cells(intCurrLine, cColumn1).Value = ""
1760                                  ElseIf rsMold("FinalSuppFlag") = "Y" Then
1770                                      wsExcel.Cells(intCurrLine, cColumn1).Value = "(" & rsMold("SUPPCODE") & ")"
1780                                  Else
1820                                      wsExcel.Range("C" & intCurrLine).Value = rsMold("SUPPCODE")

1830                                  End If
  
                                      'A06
1840                                  If Len(wsExcel.Cells(intCurrLine, cColumn1)) > 8 And Len(rsMold("MOLDCODE")) <= 10 Then
1850                                      wsExcel.Cells(intCurrLine, cColumn2).Value = "'" & toDesc2(rsMold("MOLDCODE") & vbCrLf & " ")
1860                                  Else
1870                                      wsExcel.Cells(intCurrLine, cColumn2).Value = "'" & toDesc2(rsMold("MOLDCODE"))
1880                                  End If
                                      'A06

1890                                  wsExcel.Cells(intCurrLine, cColumn3).Value = toDesc2("'" & rsMold("MOLDDESC"))
  
1900                                  If rs("ACCYTYPE") = "A" Then
1910                                      If oACCY.LoadAccyMaster(AccyMasterOne, Rights.CmpCode, Rights.DeptCode, rs("ACCYCODE")) Then
1920                                          pBaseUnit = oACCY.IAccyMaster.BaseUnit
1930                                          With oUnitExchg
1940                                              If .Load(UnitExchangeOne, Rights.CmpCode, Rights.DeptCode, rs("UNITCODE"), pBaseUnit) Then
1950                                                  wsExcel.Cells(intCurrLine, cColumn4).Value = (rs("QTY") * .IDB.ExgRate2 / .IDB.ExgRate1 / 12 * rsMold("ReqQty")) & " " & pBaseUnit
                                                      'A03
1960                                              End If
1970                                          End With
1980                                      End If
1990                                  Else    'O'
2000                                      If oOtherAccy.LoadOtherAccy(OtherAccyOne, Rights.CmpCode, Rights.DeptCode, rs("ACCYCODE")) Then
2010                                          pBaseUnit = oOtherAccy.IOtherAccy.BaseUnit
2020                                          With oUnitExchg
2030                                              If .Load(UnitExchangeOne, Rights.CmpCode, Rights.DeptCode, rs("UNITCODE"), pBaseUnit) Then

2040                                                  wsExcel.Cells(intCurrLine, cColumn4).Value = (rs("QTY") * .IDB.ExgRate2 / .IDB.ExgRate1 / 12 * (12 / rs("FORITEMQTY"))) & " " & pBaseUnit
2050                                              End If
2060                                          End With
2070                                      End If
2080                                  End If
                                      '

2090                                  wsExcel.Cells(intCurrLine, cColumn6).Value = toDesc2("'" & rsMold("COLORDESC"))
2100                                  wsTemp.Cells(Desc_Row, Desc_Col).Value = "'" & rsMold("MOLDCODE")     ''' Fit the Row Height 04.OCT.2002
2110                                  wsTemp.Cells(Desc_Row, Desc_Col + 1).Value = toDesc2("'" & rsMold("MOLDDESC"))
2120                                  wsTemp.Cells(Desc_Row, Desc_Col + 2).Value = toDesc2("'" & rsMold("COLORDESC"))
2130                                  wsTemp.Rows(Desc_Row).AutoFit
  
2140                                  wsExcel.Rows(intCurrLine).RowHeight = wsTemp.Rows(Desc_Row).RowHeight
2150                                  intPlusHeight = intPlusHeight + wsExcel.Rows(intCurrLine).RowHeight - 12.75
    
2160                                  intCurrLine = intCurrLine + 1
2170                                  .MoveNext
2180                              Wend
2190                          End If
2200                      End With


Report •
Related Solutions


Ask Question