473,395 Members | 1,885 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to structure Select statement for table & column names that contain spaces

167 100+
Once again... I am supporting another Access database that I did not build. The previous 'owner' of this built the tables with spaces in the table names as well as the column names. I am having a difficult time getting the select statement to work. I am getting a run-time error 2342. "A RunSql action requires and arguement consisting fo an SQL statement.
I am using MS Access 2007. Behind a command button on a form I am building code to select some table data based on a variable.

Table Name: Contract Info
columns:
Contract Details Included
Database ID #

Here is my code:
Dim qry as String
Dim rsTemp as New ADODB.Recordset

qry= "Select [Database ID#], [Contract Details Included] from [Contract Info] where [Database ID#] = " & vcVCID & ""
DoCmd.RunSQL qry

End of code

When the DoCmd.RunSql statement runs, I get the error. However I tested creating a query that uses the names with spaces and it works. Here is the code for my query:

Select [Database ID#], [Contract Details Included] from [Contract Info] where [Database ID#] = 2146

I was wondering if I could execute the query above and pass the variable as a parameter? Although I would love to figure out how to get the code to work building my select statement.
Mar 16 '11 #1
1 3647
ADezii
8,834 Expert 8TB
Expand|Select|Wrap|Line Numbers
  1. qry= "Select [Database ID#], [Contract Details Included] from [Contract Info] where [Database ID#] = " & vcVCID 
Mar 16 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Joe Gazda | last post by:
I'm a relative newbie to PHP, but have been able to put together some PHP code to generate a CSV/XLS file from a Query result. Now, I would like to include custom column names instead of the MySQL...
2
by: Bart Van der Donck | last post by:
Hello, I am using MySQL 4.0. Say that I have a table named "mytable" having a column "ID" and a column "test columnname". When dumping: mysqldump --opt DATABASE -uUSER -hHOST -pPASS >...
9
by: saturnius | last post by:
Hello, I am passing a value to a stored procedure in vb.net to get normally a selection of the table. How could I get the complete table without writing the code twice? Many thanks in advance ....
4
by: Warren | last post by:
I am trying to capture some data from a MS Access DB which was created and populated by a VB program I did not write. I can grab all the data but I need to grab certain columns only, problem is...
6
by: Carlo B | last post by:
Hi I need to use a listbox to display authors from the authors table in the standard BIBLIO.MDB. I haven't even got to this point yet and the code below is bombing out on the line...
0
by: zacks | last post by:
I am trying to use the Microsoft Text Driver to access data in a text file via ODBC calls. Everything has worked fine so far. I am now trying to implement support for a file that has a special...
4
by: natG | last post by:
Hi; I am transferring data from MySql to db2 using my own java/jdbc program. Working out ok, except for the fact that our apps use mixed-case names for tables and columns. Although my CREATE TABLE...
4
by: dkirkdrei | last post by:
I am having a problem getting results back from a SELECT statement using the script below. The field names contain decimals and I am not sure wether or not this is causing the problem or not?? I am...
4
by: mailsumit | last post by:
I would like to know the SQL statement for displaying only the column names of a particular table. For eg. if I have a table by the name DETAILS and it has three columns FIRST_NAME, LAST_NAME and...
1
by: sakura | last post by:
Hi. I'm using asp.net and c# language. How can i display a GridView using select statement of two column in one table? This is my coding: if (sdr.Read()) { if(namaPembekal.Equals(sdr)...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.