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 July 15th, 2009, 03:23 PM
Registered User
 
Join Date: Jul 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Variable use in an INSERT INTO statement

HI, I'm new to SQL and VBA and trying some basic things out using Access 2003. I am trying to have text boxes that are filled in, then assigned as variables and then trying to use them in an INSERT INTO statement:

Code:
Dim strSQL As String
Dim NumAss As String
Dim SimAss As String
Dim ImeiAss As String
Dim stDocName As String

SimAss = SimBox.Value
ImeiAss = ImeiBox.Value
NumAss = NumBox.Value



strSQL = "INSERT INTO Phone ([Number], [SIM Number], [IMEI Number]) VALUES (' " & NumAss & " ," & SimAss & ", " & ImeiAss & " ')"


DoCmd.RunSQL (strSQL)
This version errors saying that the number of query values and destination fields are not the same, I ahve tried it countless times with different brackets and quotation marks in different places with no joy!

Hopefully someone can point me in the right direction please!
 
Old July 15th, 2009, 04:05 PM
Registered User
 
Join Date: Jul 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

SOlved, doh sorry





Similar Threads
Thread Thread Starter Forum Replies Last Post
Complicated Insert Statement jackie25 SQL Server ASP 1 May 31st, 2006 09:08 AM
Insert Statement Iashia06 Access 0 April 7th, 2006 12:45 PM
Insert into statement not working. alisonchase Access ASP 8 January 16th, 2005 10:52 AM
Use a Variable for an Include Statement ptetz Classic ASP Basics 2 August 25th, 2003 03:52 PM





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