Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 25th, 2006, 06:38 AM
Registered User
 
Join Date: Oct 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Docmd.runsql

I am trying to update a table depending on the value in strwhere
The update statement does not recognise the variable.

Dim strwhere As Integer
Dim strsql As String
strwhere = oldTcp
strsql = "UPDATE TCPIP SET TCPIP.Allocated = 0 WHERE ((TCPIP.ID)=[strwhere]);"

  #2 (permalink)  
Old October 25th, 2006, 07:16 AM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Replace

strsql = "UPDATE TCPIP SET TCPIP.Allocated = 0 WHERE ((TCPIP.ID)=[strwhere]);"

with

strsql = "UPDATE TCPIP SET TCPIP.Allocated = 0 WHERE ((TCPIP.ID)=[" & strwhere & "]);"

The variable was earlier taken as part of the string literally

Cheers
Shasur

http://www.vbadud.blogspot.com
  #3 (permalink)  
Old October 25th, 2006, 08:21 AM
Registered User
 
Join Date: Oct 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your help, as the value is an integer I took the brackets out and it worked fine.

Saved me a lot of time.

Thanks again

Anne



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using DoCmd.RunSQL to return values jscully Access VBA 10 August 21st, 2017 12:58 PM
DoCmd.RunSQL dates and time TarkaDahl Access VBA 3 May 11th, 2006 11:19 AM
Question about DoCmd.RUNSQL using an insert statem Nasem VB Databases Basics 1 May 5th, 2006 10:15 AM
docmd.runsql "select RodMead Access VBA 2 July 31st, 2004 02:55 PM
Help with DoCmd.RunSQL command ricmar Access VBA 3 July 21st, 2004 03:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.