Hi all,
I got an error that says Syntax error, but what is wrong here.
If I use a MsgBox on Totaal4 then I see the correct number.
If I use only the statement after the ELSE that works fine.
Private Sub GrootteExplGeb_AfterUpdate()
Dim SQL As String
Dim Deel4a_MR As Double
Dim Deel4b_MR As Double
Dim Totaal4 As Double
Deel4a_MR = DLookup("Invlfact1_MR", "Basis_InvloedsfactorA_MR_Hulp", "INVLFCTR_A_MR_SK=2204")
Deel4b_MR = DLookup("Invlfact2_MR", "Basis_InvloedsfactorA_MR_Hulp", "INVLFCTR_A_MR_SK=2204")
Totaal4 = Me!GrootteExplGeb * Deel4a_MR + Deel4b_MR
If GrootteExplGeb > 70 And GrootteExplGeb <= 150 Then
SQL = "UPDATE Invloedsfactoren " & _
"SET InvlFctr_Perc = " & Totaal4 & _
"WHERE PROJNR_SK = " & Me!PROJNR_SK & _
" AND INVLFCTR_SK = 2401"
DoCmd.SetWarnings False
DoCmd.RunSQL SQL
DoCmd.SetWarnings True
'Else
' If GrootteExplGeb > 150 Then
' SQL = "UPDATE Invloedsfactoren " & _
' "SET InvlFctr_Perc = 0.8 " & _
' "WHERE PROJNR_SK = " & Me!PROJNR_SK & _
' " AND INVLFCTR_SK = 2401"
' DoCmd.SetWarnings False
' DoCmd.RunSQL SQL
' DoCmd.SetWarnings True
' End If
End If
End Sub
I got an error that says Syntax error, but what is wrong here.
If I use a MsgBox on Totaal4 then I see the correct number.
If I use only the statement after the ELSE that works fine.
Private Sub GrootteExplGeb_AfterUpdate()
Dim SQL As String
Dim Deel4a_MR As Double
Dim Deel4b_MR As Double
Dim Totaal4 As Double
Deel4a_MR = DLookup("Invlfact1_MR", "Basis_InvloedsfactorA_MR_Hulp", "INVLFCTR_A_MR_SK=2204")
Deel4b_MR = DLookup("Invlfact2_MR", "Basis_InvloedsfactorA_MR_Hulp", "INVLFCTR_A_MR_SK=2204")
Totaal4 = Me!GrootteExplGeb * Deel4a_MR + Deel4b_MR
If GrootteExplGeb > 70 And GrootteExplGeb <= 150 Then
SQL = "UPDATE Invloedsfactoren " & _
"SET InvlFctr_Perc = " & Totaal4 & _
"WHERE PROJNR_SK = " & Me!PROJNR_SK & _
" AND INVLFCTR_SK = 2401"
DoCmd.SetWarnings False
DoCmd.RunSQL SQL
DoCmd.SetWarnings True
'Else
' If GrootteExplGeb > 150 Then
' SQL = "UPDATE Invloedsfactoren " & _
' "SET InvlFctr_Perc = 0.8 " & _
' "WHERE PROJNR_SK = " & Me!PROJNR_SK & _
' " AND INVLFCTR_SK = 2401"
' DoCmd.SetWarnings False
' DoCmd.RunSQL SQL
' DoCmd.SetWarnings True
' End If
End If
End Sub