Array Coding Conversion to 2010

Joined
Apr 27, 2012
Messages
1
Reaction score
0
A version of the following code works in Access 2003 (code minus the DAO, .xlsx and acSpreadsheetTypeExcel12Xml, using 2003 attributes). When this database was converted to 2010 the code only flows through to the first to last record and doesn't export the data corresponding to the last record but rather takes the data from the first to last and names it with the last. Confusing, I know, basically if I have 5 records it exports the data using the attribute from record 4 naming it with the convention of record 5. Please let me know if you have any suggestions on how to get this puppy to work in 2010. Thanks!

Dim rst3 As DAO.Recordset
Dim strsup3 As String
Dim strsuptemp3 As String

Set rst3 = CurrentDb.OpenRecordset("tblBusMgr", dbOpenDynaset)

VarArray = rst3.GetRows(50)
rst3.Close

Do
Do While m < 9
For y = LBound(VarArray, 2) To UBound(VarArray, 2)
'For x = LBound(VarArray, 1) To UBound(VarArray, 1)
strsup3 = VarArray(0, y)
strsuptemp3 = VarArray(0, y)
If VarArray(0, y) = Null Then
Exit Do
ElseIf strsup3 = strsuptemp3 Then
Forms!frmmain.Text37 = strsup3

Tabname = "Data"
DoCmd.CopyObject "", Tabname, acQuery, "qselRepErrors"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, Tabname, "C:\Documents and Settings\" & Environ("USERNAME") & "\Desktop\ACIS Weekly Error Report Templatev3.xlsx", True
DoCmd.DeleteObject acQuery, Tabname

Set FS = CreateObject("Scripting.FileSystemObject")
FS.copyfile "C:\Documents and Settings\" & Environ("USERNAME") & "\Desktop\ACIS Weekly Error Report Templatev3.xlsx", "C:\Documents and Settings\" & Environ("USERNAME") & "\Desktop\ACIS Errors by Rep " & Sdate & "-" & strsup3 & Text59 & ".xlsx"
End If
Next y
Exit Do
Loop
Loop Until y > UBound(VarArray, 2)
FS.DeleteFile "C:\Documents and Settings\" & Environ("USERNAME") & "\Desktop\ACIS Weekly Error Report Templatev3.xlsx", True
 
Back
Top