Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 October 15th, 2004, 01:50 PM
Registered User
 
Join Date: Oct 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Pass-Through SQL Insert Query

I have a command button set up on a form to run a SQL pass-through insert query after several field are filled in but I can't get the variable syntaxs correct..

I have tried..

INSERT INTO Response (Equipment_Type, Equipment_Name, Alarm, Alarm_Status) VALUES ('[type]','[name]','[alarm]','[status]')

INSERT INTO Response (Equipment_Type, Equipment_Name, Alarm, Alarm_Status) VALUES ('[Form2]![type]','[Form2]![name]','[Form2]![alarm]','[Form2]![status]')

INSERT INTO Response (Equipment_Type, Equipment_Name, Alarm, Alarm_Status) VALUES ('Forms![Form2]![type]','Forms![Form2]![name]','Forms![Form2]![alarm]','Forms![Form2]![status]')

And none of them work, they all pass the variable syntax but not the value of the variable. Any suggestions?? Thanks in advance.

 
Old October 18th, 2004, 12:43 AM
Registered User
 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I take it they are all text fields, if so try
Dim SQL As String
SQL = "INSERT INTO Response (Equipment_Type, Equipment_Name, Alarm, Alarm_Status) VALUES ("
SQL = SQL & "'" & Forms![Form2]![Type] & "'" & "," & "'" & Forms![Form2]![name] & "'" & "," & "'" & Forms![Form2]![Alarm] & "'" & "," & "'" & Forms![Form2]![Status] & "'" & ")"
db.Execute (SQL)

phil





Similar Threads
Thread Thread Starter Forum Replies Last Post
IF statement in SQL Pass Through Query Coby Access VBA 3 February 15th, 2008 09:24 AM
How to pass Table Name as a parameter in SQL query visualbrin Reporting Services 1 October 13th, 2006 04:08 PM
Not able to pass the combo box value to SQL query sparsh2010 Access VBA 3 July 26th, 2006 07:10 AM
how to pass sql query to crystal through vb.net dranjithreddy Crystal Reports 0 June 7th, 2005 05:15 AM
How can I pass sql query through vb.net to crystal sachinbashetti Crystal Reports 0 May 14th, 2005 01:47 AM





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