Syntax problem

  • Thread starter Thread starter Frankie via AccessMonster.com
  • Start date 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.
 
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")
 
Back
Top