This code does not work. It runs without errors, but no record is ever added to the table. Any ideas what is going on. It looks right to me and is just like code I use in other places, but it doesn't work.
-I hate Microsoft!
-Forever and always forward.
Code:
Function addrecfun()
Dim Con As ADODB.Connection
Dim rsTable As ADODB.Recordset
Dim strSQL As String
Dim preOut As String
Set Con = CurrentProject.Connection
Set rsTable = New ADODB.Recordset
strSQL = ""
strSQL = strSQL & "Select *"
strSQL = strSQL & " From zTestTable2"
strSQL = strSQL & " Where (TotalType = 'Data1Total');"
With rsTable
.Open strSQL, Con, adOpenDynamic, adLockBatchOptimistic
If .BOF = False And .EOF = False Then
.MoveLast
preOut = .Fields("CurrentData").Value
Else
preOut = 0
End If
.AddNew
.Fields("Location").Value = "1"
.Fields("TotalType").Value = "Data1Total"
.Fields("Date").Value = "4"
.Fields("PreviousData").Value = preOut
.Update
.Close
End With
End Function
-I hate Microsoft!
-Forever and always forward.