Update not working

B

Brian

With regard to the following code it doesn't update the
table:

strSQL = "Update AVAILABILITY " & _
"Set AVAILABILITY.[Booking ID] = varNewID " & _
"WHERE AVAILABILITY.BookingDate=#" & _
Forms![SINGLE BOOKING AVAILABILITY]!BookingDate & _
"# And AVAILABILITY.Period=" & Forms![SINGLE
BOOKING AVAILABILITY]!Combo8 & _
" And AVAILABILITY.Room=""" & Forms![SINGLE
BOOKING AVAILABILITY]!Combo10 & """"
DoCmd.RunSQL strSQL

If I print out the strSQL it looks like this:

UPDATE AVAILABILITY SET AVAILABILITY.[Booking ID] =
varNewID WHERE AVAILABILITY.BookingDate=#08/09/2004# And
AVAILABILITY.Period=1 And AVAILABILITY.Room)="IT4"

A record exists with date 08/09/2004, period=1, room=IT4
so where does the problem lie? With the date?

Thanks.
 
J

John Spencer

What is varNEWID is it a string? or a Number?

You need to get its value and concatenate the value into your sql string.

If it is a string, then something like:

strSQL = "Update AVAILABILITY " & _
"Set AVAILABILITY.[Booking ID] =""" & varNewID & """" & _
" WHERE AVAILABILITY.BookingDate=#" & _
Forms![SINGLE BOOKING AVAILABILITY]!BookingDate & _
"# And AVAILABILITY.Period=" & Forms![SINGLE
BOOKING AVAILABILITY]!Combo8 & _
" And AVAILABILITY.Room=""" & Forms![SINGLE
BOOKING AVAILABILITY]!Combo10 & """"
 

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

Top