Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a variable in the middle of a Query

Status
Not open for further replies.

Nkuha

Programmer
Jan 8, 2002
7
0
0
US
Anyone know how to correct this code?

rst.Open "update cases SET cases.flag = 0 WHERE" & DateDiff("h", rst!datein, Now) > threshold, CurrentProject.Connection, adOpenKeyset, adLockOptimistic

 
Try this.

rst.Open &quot;update cases SET cases.flag = 0 WHERE &quot; & threshold < DateDiff(&quot;h&quot;, rst!datein, Now), CurrentProject.Connection, adOpenKeyset, adLockOptimistic

Note the extra space after the Where clause
 
Try this.

rst.Open &quot;update cases SET cases.flag = 0 WHERE &quot; & threshold < DateDiff(&quot;h&quot;, rst!datein, Now), CurrentProject.Connection, adOpenKeyset, adLockOptimistic

Note the extra space after the Where clause

No Two Nulls are the same

Matt
 
I don't think this is going to work.

You're trying to open a recordset, rst, but you're also trying to use the recordset inside of the UPDATE statement. Which I don't think exists at that point.

Without knowing more about what you're doing, my guess is that the DateDiff should be done on a field in the Cases table.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top