I am trying to run this code/query:
The query updates some fields in a table based on a date comparison. (whether or not the date the user entered is > than a date in the table.)
When I run the query from design mode (the red "!"), it works. When I try to run it via this method, it does not work.
The ONLY thing I can think of is that I am passing a parameter to it via a control on a subform in an if, then, else.
These are the 2 dates I am comparing. [AwardTbl]![AwardDate] and [Forms]![AstProfileFrm]![AstProfileAward Frm].[Form]![SepDateTxt].
In VBA, I captured the value of SepDateTxt, and in debug mode it was correct. Also, like previously stated, it runs fine when ran manually.
Is this an issue with passing in a parameter or am I just doing something completely wrong? I cannot figure out why it won't work.
Edit: I tried the
method, and it threw an error saying "Too few parameters, expected 2". One parameter is the EmployeeID coming off of the parent form, and the other is the Date field SepDateTxt.
I tested the validity of both of them, via
and they both had the correct values.
Code:
DoCmd.OpenQuery "ForfeitVestingDateUpdateQry"
When I run the query from design mode (the red "!"), it works. When I try to run it via this method, it does not work.
The ONLY thing I can think of is that I am passing a parameter to it via a control on a subform in an if, then, else.
Code:
If([AwardTbl]![VestingDate]>Date(),[Forms]![AstProfileFrm]![AstProfileAwardFrm].[Form]![SepDateTxt],[AwardTbl]![VestingDate])
In VBA, I captured the value of SepDateTxt, and in debug mode it was correct. Also, like previously stated, it runs fine when ran manually.
Is this an issue with passing in a parameter or am I just doing something completely wrong? I cannot figure out why it won't work.
Edit: I tried the
Code:
db.Execute
I tested the validity of both of them, via
Code:
Dim EmpID As Long Dim SepDate As Date EmpID = Me.Parent!EmployeeID SepDate = Me!SepDateTxt
Comment