Still learning VBA, so please bear with me. I have an If Then Statement which if the criteria is true, it executes, otherwise it should do nothing. When I execute the code (click the add record button), the following error results when the value is 2 or Null or blank,
Now when I debug, the following code is highlighted,
I have tried using an ELSE statement where add_cbo_calculate = 2 Or Isnull Or "". But something keeps telling me that is not necessary, as if the criteria add_cbo_calculate does not equal one, it should not execute.
Any help for a VBA beginner is greatly appreciated!
Thanks
Run-time error '-2147217908(80040e0c)':
Command text has not been set for the command object.
Command text has not been set for the command object.
Now when I debug, the following code is highlighted,
Code:
'Modifys last month to accept remainder value of total target enrollment if not divisible by whole numbers
If add_cbo_calculate = 1 Then
sql5 = "Update dbo_Monthly_Expectations "
sql5 = sql5 & "Set Exp_Recruitment= " & (-Int(-(Numtoenroll) Mod (Monthstoadd)) + (-Int(-(Numtoenroll) \ (Monthstoadd))))
sql5 = sql5 & " Where Reporting_Month= " & DMax("Reporting_Month", "dbo_monthly_expectations", "study_id='" & Me.Add_Study_ID & "'")
End If
[COLOR="Red"][B]cn.Execute sql5[/B][/COLOR]
I have tried using an ELSE statement where add_cbo_calculate = 2 Or Isnull Or "". But something keeps telling me that is not necessary, as if the criteria add_cbo_calculate does not equal one, it should not execute.
Any help for a VBA beginner is greatly appreciated!
Thanks