473,387 Members | 1,863 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,387 software developers and data experts.

ALTER TABLE statement producing Syntax Error

I am trying to create a macro to change a data type in a column. The table was created using a "make-table" query, and the column(s) I want to modify were created using a calculation in my query. Therefore, the data in the column has a lot of numbers after the decimal.

I could go into the table's design view and change the decimals from Auto to 2, and the format to Percent, however I would like this to happen automatically after the make-table query runs.

So, I created a macro. So far all I have in the macro is a RunSQL statement that looks like this:

Alter table [1 - Alert Report Export - Dept,Reg,Mo] ALTER COLUMN [Planned Growth] float(10,2)

I get a Syntax Error when I try to run this. Interestingly, if I chnange the data type to Text(50) it works.

What am I doing wrong? Is there a better way to get where I'm going?

Your help is appreciated.
Jan 23 '08 #1
4 3507
FishVal
2,653 Expert 2GB
Hello, JenavaS.

Actually field type (you try to set) is not the same as field property (you should set). You may try the following code to set "DecimalPlaces" property of a field
Expand|Select|Wrap|Line Numbers
  1. CurrentDb.TableDefs("YourTableName").Fields("YourFieldName").Properties("DecimalPlaces").Value=4
  2.  

Regards,
Fish
Jan 23 '08 #2
I tried this and get the error Property Not Found.

This is my code:

CurrentDb.TableDefs("1 - Alert Report Export - Dept,Reg,Mo").Fields("Planned Growth").Properties("decimal places").Value = 4
Jan 23 '08 #3
I also tried this:

CurrentDb.TableDefs("1 - Alert Report Export - Dept,Reg,Mo").Fields("Planned Growth").Properties("decimalplaces").Value = 4

And get a Property not found error.
Jan 23 '08 #4
You got me pointed in the right direction, but this acticle explains more in depth what has to be done to acheive this:

http://visualbasic.about.com/od/usevb6/l/aa101602a.htm

Essentially one must first add the property to the collection, then update it.
Jan 23 '08 #5

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

Similar topics

0
by: Adam Fortuno | last post by:
Was in the midst of doing something today and I attempted to drop a number of columns in a table with the following: ALTER TABLE tmp DROP COLUMN col_1, col_2, col_3, col_4; Unfortunately MySQL...
10
by: Jane | last post by:
Does any one know why this statement is failing? db2 => ALTER TABLE ELMT_T ALTER COLUMN CDTY_CD SET DATA TYPE VARCHAR(51) DB21034E The command was processed as an SQL statement because it was...
5
by: Mike L | last post by:
Hello all I'm trying to migrate a BE from Access to SQL Server. I've been making changes to the Access BE from the FE with SQL statements, and want to do the same with the BE in SQL Server. ...
1
by: Jens | last post by:
Hi, Does anyone know if it is possible to alter an access table through ODBC. I am using the following SQL statement to add a foreign key to a table. Access returns an error like "Syntax error...
9
by: Jack | last post by:
Hi, I am gathering the input values to a form using Request.form method from the processing page. After all the data is captured, I am building sql statement out of it. Using a response.write...
1
by: vasilip | last post by:
I'm testing out db2 for a project I'm starting that requires proper xml support and I can't seem to get both xml and spatial data to work well in the same table. Once having created a table...
1
by: ymk | last post by:
Simple SQL question. I am trying to add multiple columns to a temp table and the alter statement throws the following error. Server: Msg 170, Level 15, State 1, Line 1 Line 1: Incorrect syntax...
3
by: Deano | last post by:
Hi, I just want to add a text column to a table in my code. I can't find a simple example of this. dbs.Execute ("ALTER tblCCOccurrences ADD COLUMN Year1 Text;"). This gives me; Syntax...
1
by: cmartin1986 | last post by:
Hi, I am trying to write code to change my table data types. what i have so far is: currentdb.execute "alter table getdates alter column Line Unit 0001 date" If I leave it at that it...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.