Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA 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
 
Old August 16th, 2006, 06:11 AM
Registered User
 
Join Date: Aug 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using INSERT INTO with a string Variable

I have looked and looked and looked, i am trying to insert a string into a Table using the following code:

InsertTest = "Monkey"
strSQL = "INSERT INTO Holder_tbl (Company, PolicyNo) VALUES (" & InsertTest & ",'TEST')"

When i run the SQL code it asks me to enter the Value for "Monkey" but "Monkey" is meant to be the value. Ive been starring at this code for so long i think i might explode, any help would be much appreciated.. if this makes any sense :P

Sus

 
Old August 16th, 2006, 06:50 AM
Registered User
 
Join Date: Aug 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dont you hate it when you finally give in to asking then figure it out yourself...

InsertTest = "Monkey"
strSQL = "INSERT INTO Holder_tbl (Company, PolicyNo) VALUES ('" & InsertTest & "','TEST')"

just missing a couple of "Tics"

 
Old January 6th, 2015, 11:25 AM
Registered User
 
Join Date: Jan 2015
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Same error...

Why do I receive a syntax error message for this?


DoCmd.RunSQL "INSERT INTO timestamp_data (timestamp) VALUES ('" & timestamp_buffer & "')"

where timestamp_data is the table, timestamp is the field, and timestamp_buffer is the string variable.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable Usage in Insert Command tara0308 Access VBA 7 July 30th, 2007 12:50 PM
Insert Variable Value into DB Deano252 ASP.NET 2.0 Basics 1 June 24th, 2006 03:21 AM
Using SQL Insert into with a variable erichoangnguyen Access VBA 3 May 3rd, 2005 01:40 PM
How to insert variable value into regex.pattern? Batch Classic ASP Basics 3 January 3rd, 2005 05:07 PM
insert value of variable into an existing table mountaindew7612 SQL Server 2000 5 October 16th, 2004 12:48 PM





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