Help with SQL syntax

  • Thread starter Thread starter Alan Fisher
  • Start date Start date
A

Alan Fisher

Im having problems with the following SQL statement. It
works fine without "HoursFlown = " & sngActHours. I need
to SET both HoursScheduled and HoursFlown but I don't know
how to do it. I tried using a ";" between the two but it
still errors. I know it's just a matter of syntax but
can't seem to get it working. Thanks for your help.


qdf.SQL = "UPDATE WingSchedule SET HoursScheduled = " _
& sngSchedHours _& "HoursFlown = " & sngActHours _
& " WHERE AirSpace = '" & strCurMoa & "'" _
& " And " & " Date = #" & datCurDay & "#" _
& " AND " & "Wing ='" & strCurWing & "'"
qdf.Execute
 
-----Original Message-----
Im having problems with the following SQL statement. It
works fine without "HoursFlown = " & sngActHours. I need
to SET both HoursScheduled and HoursFlown but I don't know
how to do it. I tried using a ";" between the two but it
still errors. I know it's just a matter of syntax but
can't seem to get it working. Thanks for your help.


qdf.SQL = "UPDATE WingSchedule SET HoursScheduled = " _
& sngSchedHours _& "HoursFlown = " & sngActHours _
& " WHERE AirSpace = '" & strCurMoa & "'" _
& " And " & " Date = #" & datCurDay & "#" _
& " AND " & "Wing ='" & strCurWing & "'"
qdf.Execute
.
I figured it out myself. I needed a comma to separate the
two not a semi-colon.
 
qdf.SQL = "UPDATE WingSchedule SET HoursScheduled = " _
& sngSchedHours _ & " HoursFlown = " & sngActHours _
& " WHERE (((AirSpace) = '" & strCurMoa & "')" _
& " And " & " ((Date) = #" & datCurDay & "#)" _
& " AND " & "((Wing) ='" & strCurWing & "'));"


I insert between sngSchedHours and HoursFlown a space " "
I insert "()" and ";"
Good practice is to repeat the name of table before each
field. Create one query in query wizard and take a look
for sql statement.
 
Back
Top