troubleshooting Question

Code crashes on "Win 7 - Office 2010" but works on "Win XP - Office 2003"

Avatar of 24Carat
24CaratFlag for Belgium asked on
Visual Basic ClassicMicrosoft Excel
4 Comments1 Solution308 ViewsLast Modified:
Hi Experts!

I have this piece of code i'm usign for a while now.
Since upgrading to Win7 and Office 2010 this codes allways lets excel crash.
Any suggestions on what is should change?

Regards,
24C


Here's the code:

    Range("A1").Select
    vStartRange = "A1"
    vStopRange = Range("F1").End(xlDown).Offset(0, 8).Address(RowAbsolute:=False, ColumnAbsolute:=False)
    Set rnActReg = Range(vStartRange & ":" & vStopRange)
    iRows = rnActReg.Rows.Count
    imaxID = 0
    For iCounter = 1 To iRows
            vrArtCode = rnActReg(iCounter, 6).Value
            vrKlrCode = rnActReg(iCounter, 7).Value
            Application.StatusBar = vrArtCode & "_" & vrKlrCode

            varSQLcmd = "SELECT "
            varSQLcmd = varSQLcmd & "`productlist`.`ID`, "
            varSQLcmd = varSQLcmd & "`productlist`.`active`, "
            varSQLcmd = varSQLcmd & "`productlist`.`categorie`, "
            varSQLcmd = varSQLcmd & "`productlist`.`artcode`, "
            varSQLcmd = varSQLcmd & "`productlist`.`kleurcode`, "
            varSQLcmd = varSQLcmd & "`productlist`.`artomschr`, "
            varSQLcmd = varSQLcmd & "`productlist`.`artomschr2`, "
            varSQLcmd = varSQLcmd & "`productlist`.`kleuromschr`, "
            varSQLcmd = varSQLcmd & "`productlist`.`artdim`, "
            varSQLcmd = varSQLcmd & "`productlist`.`prijs`, "
            varSQLcmd = varSQLcmd & "`productlist`.`levartcode`, "
            varSQLcmd = varSQLcmd & "`productlist`.`levnaam`, "
            varSQLcmd = varSQLcmd & "`leveranciers`.`Naamzaak` "
            varSQLcmd = varSQLcmd & "FROM "
            varSQLcmd = varSQLcmd & "`productlist` "
            varSQLcmd = varSQLcmd & "Left Join `leveranciers` ON `productlist`.`levnaam` = `leveranciers`.`Code` "
            varSQLcmd = varSQLcmd & "WHERE artcode = '" & vrArtCode & "' AND kleurcode = '" & vrKlrCode & "' "
           
            SQLajudyCONNECT
            If rs.RecordCount > 0 Then
                    For i = 1 To rs.RecordCount
                            
                            If imaxID < rs.Fields("ID").Value Then imaxID = rs.Fields("ID").Value
                            
                            rnActReg(iCounter, 1).Value = rs.Fields("levnaam").Value
                            rnActReg(iCounter, 2).Value = rs.Fields("naamzaak").Value
                            rnActReg(iCounter, 3).Value = rs.Fields("levartcode").Value
                            rnActReg(iCounter, 4).Value = rs.Fields("active").Value
                            rnActReg(iCounter, 5).Value = rs.Fields("categorie").Value
                            
                            
                            rnActReg(iCounter, 8).Value = rs.Fields("artomschr").Value & " - " & rs.Fields("artomschr2").Value & " - " & rs.Fields("kleuromschr").Value
                            rnActReg(iCounter, 9).Value = rs.Fields("prijs").Value
                    Next i

            End If
    Next
Application.StatusBar = False
ASKER CERTIFIED SOLUTION
24Carat

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros