A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Update not working



 
 
Thread Tools Display Modes
  #1  
Old May 6th, 2004, 12:20 AM
Brian
external usenet poster
 
Posts: n/a
Default Update not working

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.

  #2  
Old May 6th, 2004, 01:06 AM
John Spencer
external usenet poster
 
Posts: n/a
Default Update not working

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 & """"

Brian wrote:

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.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:42 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.