I have a table called TotalInterest with a field call TotInt. In my code below I am trying to take the value currently in TotInt and add to it the value in YESTERDAYS_INT_Calc from the table Daily Interest. Also, Im not sure I somehow have to loop this as there are many files I am tracking interest for.
Everything seems to work except for the lines in red below.
Thanks for any help
Private Sub Form_Open(Cancel As Integer)
Dim maxDate As Date
Dim x As Currency
Dim y As Currency
Dim z As Currency
maxDate = DMax("SystemDate", "SystemDate")
If maxDate = Date Then
Else
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO SystemDate (SystemDate) VALUES (Date());"
DoCmd.SetWarnings True
DoCmd.OpenQuery ("Daily Interest")
x = CurrentDb.OpenRecordset("select YESTERDAYS_INT_Calc from [Daily Interest]")(0)
y = CurrentDb.OpenRecordset("select TotInt from TotalInterest")(0)
z = x + y
CurrentDb.Execute ("insert into TotalInterest (TotInt) values (" & z & ")")
End If
End Sub
Everything seems to work except for the lines in red below.
Thanks for any help
Private Sub Form_Open(Cancel As Integer)
Dim maxDate As Date
Dim x As Currency
Dim y As Currency
Dim z As Currency
maxDate = DMax("SystemDate", "SystemDate")
If maxDate = Date Then
Else
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO SystemDate (SystemDate) VALUES (Date());"
DoCmd.SetWarnings True
DoCmd.OpenQuery ("Daily Interest")
x = CurrentDb.OpenRecordset("select YESTERDAYS_INT_Calc from [Daily Interest]")(0)
y = CurrentDb.OpenRecordset("select TotInt from TotalInterest")(0)
z = x + y
CurrentDb.Execute ("insert into TotalInterest (TotInt) values (" & z & ")")
End If
End Sub