I am attempting to have an action query populate the "Age" field of my demographics table. I want my input form to run the action query after the DOB field has been updated as to populate that field as the form is being completed. However, I continue to get "Compile Error: Argument Not Optional" I know my error must be simple, but I, being the tyro that I am, am clueless. Here is my code:
My "MySQL" command is all on one line and appears to be in the correct syntax. The query runs perfectly outside of its attachment to the form.
Thanks in advance.
Code:
Private Sub DOB_AfterUpdate()
DoCmd.RunSQL 'UPDATE tblDemographics SET tblDemographics.Age = DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")<Format([DOB],"mmdd")))'
End Sub
My "MySQL" command is all on one line and appears to be in the correct syntax. The query runs perfectly outside of its attachment to the form.
Thanks in advance.