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  

RunSQL asking for a parameter



 
 
Thread Tools Display Modes
  #1  
Old May 5th, 2004, 11:57 PM
Brian
external usenet poster
 
Posts: n/a
Default RunSQL asking for a parameter

I have a form with a button that executes some code which
amongst other things includes:

MsgBox varNewID
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

I get a popup box asking 'Enter a parameter value'
VarNewID. Why? The message before the strSQL shows that
varNewID contains a value such as 77.

What have I got wrong? Thanks.

  #2  
Old May 6th, 2004, 12:58 AM
DebbieG
external usenet poster
 
Posts: n/a
Default RunSQL asking for a parameter

At quick glance it looks like you're missing the " & before varNewID.

"Set AVAILABILITY.[Booking ID] = " & varNewID & _

HTH,
Debbie


"Brian" wrote in message
...
I have a form with a button that executes some code which
amongst other things includes:

MsgBox varNewID
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

I get a popup box asking 'Enter a parameter value'
VarNewID. Why? The message before the strSQL shows that
varNewID contains a value such as 77.

What have I got wrong? Thanks.

  #3  
Old May 6th, 2004, 02:13 PM
John Spencer (MVP)
external usenet poster
 
Posts: n/a
Default RunSQL asking for a parameter

Answered elsewhere. You need to get the value of varNewID into the query
string. The SQL query does not recognize the VarNewID as a variable. So change
the second line of your query string as follows

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:

I have a form with a button that executes some code which
amongst other things includes:

MsgBox varNewID
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

I get a popup box asking 'Enter a parameter value'
VarNewID. Why? The message before the strSQL shows that
varNewID contains a value such as 77.

What have I got wrong? 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 10:28 AM.


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