G
Guest
I am trying to run the following sql from the vba behind a button on a form:
sql = "INSERT INTO tblScorecardActivity ( PaperReqID, ReqTypeID,
ActivityMeasure, BD, IntakeTargetDate ) " & _
"SELECT " & Me.PaperReqID & ", RequestTypeID, Activities, BD, " &
DateAdd("d", [tblkpActivity].[BD], Date) & "" & _
" FROM tblkpActivity" & _
" WHERE ReqTypeID ='" & Me.ReqTypeID & "'"
db.Execute sql, dbFailOnError
The syntax problem I am having is with the dateadd expression. I get the
error message that jet engine can not find the field [!], I am thinking it is
[BD].
However, the following syntax works from the append query:
INSERT INTO tblScorecardActivity ( PaperReqID, ReqTypeID, ActivityMeasure,
BD, IntakeTargetDate )
SELECT [Forms]![frmScorecardMain]![PaperReqID] AS PaperReqID,
tblkpActivity.RequestTypeID, tblkpActivity.Activities, tblkpActivity.BD,
DateAdd("d",[BD],Date()) AS IntakeTargetDate
FROM tblkpActivity;
I have tried tblkpActivity.BD on the form but if I write the expression as
follows I get type mismatch:
DateAdd("d", " & [BD] & ", Date) & ""
can some one show me the right syntax?
thanks
Al
sql = "INSERT INTO tblScorecardActivity ( PaperReqID, ReqTypeID,
ActivityMeasure, BD, IntakeTargetDate ) " & _
"SELECT " & Me.PaperReqID & ", RequestTypeID, Activities, BD, " &
DateAdd("d", [tblkpActivity].[BD], Date) & "" & _
" FROM tblkpActivity" & _
" WHERE ReqTypeID ='" & Me.ReqTypeID & "'"
db.Execute sql, dbFailOnError
The syntax problem I am having is with the dateadd expression. I get the
error message that jet engine can not find the field [!], I am thinking it is
[BD].
However, the following syntax works from the append query:
INSERT INTO tblScorecardActivity ( PaperReqID, ReqTypeID, ActivityMeasure,
BD, IntakeTargetDate )
SELECT [Forms]![frmScorecardMain]![PaperReqID] AS PaperReqID,
tblkpActivity.RequestTypeID, tblkpActivity.Activities, tblkpActivity.BD,
DateAdd("d",[BD],Date()) AS IntakeTargetDate
FROM tblkpActivity;
I have tried tblkpActivity.BD on the form but if I write the expression as
follows I get type mismatch:
DateAdd("d", " & [BD] & ", Date) & ""
can some one show me the right syntax?
thanks
Al