Syntax problem

  • Thread starter Frankie via AccessMonster.com
  • Start date
F

Frankie via AccessMonster.com

I wrote the following code in the AfterUpdate event of a form which returns
syntax problem and I can't find it.
Can someone help me please ?

"If Not IsNull(Me!DateJour) Then
CurrentDb.Execute "UPDATE T_RHC SET " _
& "NumSemaine = " & DatePart("ww", Me!DateJour, 2) & ", " _
& "JourSem = " & Format(DatePart("w", Me!DateJour), "dddd") & "
WHERE IDContrat = " _
& Me!IDContrat, dbFailOnError
End If"

Thanks In advance
Frankie.
 
D

Douglas J. Steele

Since you're trying to put text into JourSem, you need quotes around the
value you're using:

"If Not IsNull(Me!DateJour) Then
CurrentDb.Execute "UPDATE T_RHC SET " _
& "NumSemaine = " & DatePart("ww", Me!DateJour, 2) & ", " _
& "JourSem = " & Chr$(34) & Format(DatePart("w", Me!DateJour),
"dddd") & Chr$(34) & "
WHERE IDContrat = " _
& Me!IDContrat, dbFailOnError
End If"

If either NumSemaine or IDContrat are text, you'll need to do the same there
as well.

Note, though, that what you're trying to store in JourSem probably isn't
what you want. Assuming you want the weekday of DateJour, get rid of the
DatePart("w", Me!DateJour), and simply use Format(Me!DateJour, "dddd")
 
F

Frankie via AccessMonster.com

Thank you very much for your help. It works great !!
Frankie.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Subform control reference prpblem 6
Error 3075 2
Syntax error 8
Error 3122 in Query 2
Syntax problem - probably with partdate? 6
Syntax error on Update 2
Error 3075 5
Docmd.Setwarning False Not Working 7

Top