Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Add Long Text Column to Access Table Via Query

I am updating a table in a .mdb format Access database with Access 2013. I want to add a new field, lets say a Description field, to an existing table.

I can add a text column using the following query

ALTER TABLE TestTable ADD Description TEXT(255);

Alternatively I could use

ALTER TABLE TestTable ADD Description varchar(255);

This works fine, and adds a column to TestTable called Description that is limited to 255 characters. If I open the table in Design View, I can see that the type of Description is listed as "Short Text". However, there is an option there to have the field be of type "Long Text" which as far as I can tell doesn't have a character limit. It is easy to manually change the type from the Design View, but I want to know if I can do this via a query.

I tried increasing the character count in my original query like so

ALTER TABLE TestTable ADD Description TEXT(300);

But then I recieve the error "Size of field 'Description' is too long."

What I want to know is can I add the column via a query such that it has a character limit greater than 255? This query is run as part of a macro that is run automatically, so I don't want to have to change it manually. My attempts at searching for a solution via Google have so far come up empty.

like image 357
jaredk Avatar asked Feb 18 '14 15:02

jaredk


People also ask

How do I increase the field size more than 255 in Access?

You need to set the Text Format to Rich Text in the Design View Property Sheet for each control bound to a Long Text (Memo) field. By default it is set to Plain Text which effectively limits the input to 255 characters. Save this answer.

How do you do long Text in Access?

In most cases, Access uses Text Box controls to display Short Text or Long Text fields. However, when you add a Long Text field to a view in an Access web app, Access creates a Multiline Textbox. When using a Multiline Textbox in the browser, you can press Enter to move to a new line in the textbox.

How do I add a column to a SQL query in Access?

Add the column in Design viewOn the Access status bar, click Design View. In the Field Name column, select a blank row and type a name for the new field. In the Data Type column, next to your new field name, select a data type for the new column. Save your changes.


1 Answers

Found the answer shortly after posting the question. Using the query

ALTER TABLE TestTable ADD Description LONGTEXT;

creates a new column of type "Long Text". It should be noted that a character count was not necessary for this type.

like image 90
jaredk Avatar answered Sep 27 '22 20:09

jaredk