I have been reading some articles on the site and I can't really find out how to make them work with what I have. I need some help.
Here is what I have -
It keeps failing at the Records.EDIT
What am I missing?
Here is what I have -
It keeps failing at the Records.EDIT
What am I missing?
Code:
Dim appExcel As Object
Dim workBook As Object
Dim workSheet As Object
Dim i As Integer
Dim FdrID As Integer
Dim dbs_curr As Database
Dim records As Recordset
Dim sqlStatement As String
Dim Message As String
Set dbs_curr = CurrentDb
Dim returnValue As Integer
Select Case returnValue
Case vbCancel:
Exit Function
Case vbNo
Application.FollowHyperlink "http://powerdelivery.southernco.com/apc/distribution/eng-svcs/SGIG/SGIG.html", , True, True
Exit Function
Case vbYes
End Select
DoCmd.OpenForm "frmRunningQuery"
Forms!frmRunningQuery.Repaint
'Delete all existing CSS informatin
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE tblTest SET tblTest.feederID = Null, tblTest.Description = Null, tblTest.CSSCustomers = Null, tblTest.CSSRevenue = Null, tblTest.ADDSCircuitMiles = Null, tblTest.SAIFI = Null, tblTest.SAIDI = Null, tblTest.MAIFI = Null, tblTest.OpCenter = Null, tblTest.Region = Null, tblTest.SubstationUnit = Null, tblTest.NextDate = Null, tblTest.CompleteDate = Null, tblTest.StartDate = Null, tblTest.ReviewDate = Null, tblTest.ReviewedDate = Null, tblTest.TotalPoles = Null;"
DoCmd.SetWarnings True
' Open an existing spreadsheet
Set appExcel = GetObject("C:\CSS.xls")
Set workSheet = appExcel.Worksheets(1)
sqlStatement = "SELECT tblTest.* FROM tblTest"
Set records = dbs_curr.OpenRecordset(sqlStatement, dbOpenDynaset, dbSeeChanges, dbOptimistic)
records.Edit
records!feederID = workSheet.Cells.Range("B" & i & ":B" & i).Value
records!Description = workSheet.Cells.Range("C" & i & ":C" & i).Value
records!CSSCustomers = workSheet.Cells.Range("D" & i & ":D" & i).Value
records!CSSRevenue = workSheet.Cells.Range("E" & i & ":E" & i).Value
records!ADDSCircuitMiles = workSheet.Cells.Range("F" & i & ":F" & i).Value
records!SAIFI = workSheet.Cells.Range("G" & i & ":G" & i).Value
records!SAIDI = workSheet.Cells.Range("H" & i & ":H" & i).Value
records!MAIFI = workSheet.Cells.Range("I" & i & ":I" & i).Value
records!OpCenter = workSheet.Cells.Range("K" & i & ":K" & i).Value
records!Region = workSheet.Cells.Range("M" & i & ":M" & i).Value
records!SubstationUnit = workSheet.Cells.Range("P" & i & ":P" & i).Value
records!NextDate = workSheet.Cells.Range("R" & i & ":R" & i).Value
records!CompleteDate = workSheet.Cells.Range("S" & i & ":S" & i).Value
records!StartDate = workSheet.Cells.Range("T" & i & ":T" & i).Value
records!ReviewDate = workSheet.Cells.Range("U" & i & ":U" & i).Value
records!ReviewedDate = workSheet.Cells.Range("V" & i & ":V" & i).Value
records!TotalPoles = workSheet.Cells.Range("W" & i & ":W" & i).Value
records.Update
' Release objects
Set workSheet = Nothing
Set workBook = Nothing
Set appExcel = Nothing
DoCmd.Close acForm, "frmRunningQuery"
MsgBox "Done"
End Function
Comment