We help IT Professionals succeed at work.

sql, issue

Derek Brown
Derek Brown used Ask the Experts™
on
I must be missing something here:

strSQL = _
"UPDATE ItemQuery SET ItemQuery.ItemDateCreated = Date()"
"WHERE ItemNumber=" & ItemNumber7
CurrentDb.Execute strSQL, dbFailOnError

The ItemNumber7 is a field name on the current form
The Where Clause is highlighted in Red in the code window.  I guess I have a comma missing somewhere
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Your missing an & and a _ as well as an extra space before where:
strSQL = _
"UPDATE ItemQuery SET ItemQuery.ItemDateCreated = Date()" & _
" WHERE ItemNumber=" & ItemNumber7
CurrentDb.Execute strSQL, dbFailOnError

Open in new window

Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010

Commented:
to clarify Anders comment,

Whenever you wrap a line of code to the next line, you must use the underscore ( _ ) as the final character in the line, which you did for line 1, and an ampersand to merge the two lines of code.  And when you merge two lines of code you need to make sure there is a space between the word that ends the first line and the word that begins the second line.  Otherwise:

Date() WHERE

becomes

Date()WHERE

which would generate an error at run time

HTH
Dale

Author

Commented:
Solved

Thank you.

Just to be clear, when you atribute the solution to an expert but also indicate some else helped, How are points distributed to contributors?

Author

Commented:
I'm getting error missing two patameters with:

strSQL = _
"UPDATE ItemQuery SET ItemQuery.ItemDateCreated = Date()" & _
" WHERE ItemNumber=" & ItemNumber7
CurrentDb.Execute strSQL, dbFailOnError

Can't see it