sportsguy
Finance wiz, Access hack
- Local time
- Yesterday, 20:13
- Joined
- Dec 28, 2004
- Messages
- 363
Here is the code,
the FOR loop is not recognizing the .EOF,
it used to work correctly, now it doesn't. . what might have changed?
thanks
sportsguy
the FOR loop is not recognizing the .EOF,
it used to work correctly, now it doesn't. . what might have changed?
Code:
Private Sub MassUpdate_DblClick(Cancel As Integer)
upSQL = "UPDATE DATA INNER JOIN FORECAST ON (DATA.YYYYMM = FORECAST.YYYYMM) AND (DATA.Year = FORECAST.Year) AND " _
& "(DATA.District = FORECAST.District) AND (DATA.ProductLine = FORECAST.ProductLine) AND (DATA.Type = FORECAST.Type) AND " _
& "(DATA.Account = FORECAST.Account) SET FORECAST.OCT = DATA.[OCT], FORECAST.NOV = DATA.[NOV], FORECAST.[DEC] = DATA.[DEC], " _
& "FORECAST.QTR1 = [DATA].[QTR 1], FORECAST.JAN = [DATA].[JAN], FORECAST.FEB = [DATA].[FEB], FORECAST.MAR = [DATA].[MAR], " _
& "FORECAST.QTR2 = [DATA].[QTR 2], FORECAST.APR = [DATA].[APR], FORECAST.MAY = [DATA].[MAY], FORECAST.JUN = [DATA].[JUN], " _
& "FORECAST.QTR3 = [DATA].[QTR 3], FORECAST.JUL = [DATA].[JUL], FORECAST.AUG = [DATA].[AUG], FORECAST.SEP = [DATA].[SEP], " _
& "FORECAST.QTR4 = [DATA].[QTR 4], FORECAST.FYTOTAL = [DATA].[FISCAL YEAR], FORECAST.LastUpdate = [DATA].[LastSave] " _
& "WHERE (((FORECAST.ImportTime)<[DATA].[LastSave])); "
If IsNull(Me!ComboPaths) Then
MsgBox "Please Select the folder path in the Drop Down Box", vbCritical, "TYCO SimplexGrinnell"
DoCmd.GoToControl "ComboPaths"
Exit Sub
Else
End If
On Error GoTo Err_MassUpdate_DblClick
DoCmd.DeleteObject acTable, "DATA"
Dim cnnLocal As New ADODB.Connection
Dim rstCurr As New ADODB.Recordset
Set cnnLocal = CurrentProject.Connection
Counter = 0
rstCurr.Open "SELECT CONTROL.RevisionFileName FROM CONTROL WHERE (((CONTROL.Visible)=Yes));", cnnLocal, adOpenStatic, adLockPessimistic
With rstCurr
Do Until .EOF
For Each fldCurr In .Fields
anyFileName = fldCurr.Value
anyPath = Forms!MassImport.[ComboPaths] & "\" & anyFileName & ".xls"
DoCmd.SetWarnings False
If Dir(anyPath) <> "" Then
Debug.Print anyPath
Counter = Counter + 1
On Error GoTo SecondTry
DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel9, "DATA", anyPath, True, "ACCESSPASTE"
DoCmd.RunSQL upSQL
DoCmd.DeleteObject acTable, "DATA"
GoTo Done
SecondTry:
DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel9, "DATA", anyPath, True, "ACCESS!$A$1:$X$341"
DoCmd.RunSQL upSQL
DoCmd.DeleteObject acTable, "DATA"
Done:
End If
Next
.MoveNext
Loop
End With
rstCurr.Close
Set cnnLocal = Nothing
Set rstCurr = Nothing
MsgBox Counter + "Available Files Updated Successfully", vbOKOnly, "TYCO Simplex Grinnell"
Exit_MassUpdate_DblClick:
DoCmd.SetWarnings True
Exit Sub
Err_MassUpdate_DblClick:
If Err.Number = 7874 Then
Resume Next
ElseIf Err.Number = 13 Then
Resume Done
Else
MsgBox Err.Number & " - " & Err.Description
Debug.Print "Error File" & anyPath & " - " & Err.Number & " - " & Err.Description
GoTo Exit_MassUpdate_DblClick
End If
End Sub
thanks
sportsguy