Change Data Type from Memo to Text

I have to fields called 'NAME' and 'CLIENTID' in a table called 'LOCATIONS'. 
They are in the Memo format  but need to be converted to text. How do I 
change the format using VBA? In kow this has been asked in different way 
before, but none of the other examples seem to help.
Thank you so much for you help
0
Utf
12/8/2009 5:09:01 PM
access.modulesdaovba 1670 articles. 0 followers. Follow

3 Replies
2794 Views

Similar Articles

[PageSpeed] 59

Once a field has been added to the table's Fields collection, you can't 
actually change it using VBA.

I believe you should be able to run a DDL (Data Definition Language) query 
along the lines of:

ALTER TABLE MyTableName ALTER COLUMN MyMemoField TEXT(255)

but unfortunately I've only got Access 97 on this machine, so I can't test 
to confirm.


-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"rscott927" <rscott927@discussions.microsoft.com> wrote in message 
news:5BEF8540-D3C0-4E55-B9D0-02AE57DB6642@microsoft.com...
>I have to fields called 'NAME' and 'CLIENTID' in a table called 
>'LOCATIONS'.
> They are in the Memo format  but need to be converted to text. How do I
> change the format using VBA? In kow this has been asked in different way
> before, but none of the other examples seem to help.
> Thank you so much for you help 


0
Douglas
12/8/2009 5:30:38 PM
below is the code to do the exact opposite.  You should have no problem to 
switch it around to suit your need.  At the very least it demonstrates one 
method to do this.

'---------------------------------------------------------------------------------------
' Procedure : SwitchFieldType
' Author    : CARDA Consultants Inc.
' Website   : http://www.cardaconsultants.com
' Purpose   : Switch a given table field to Memo in an external database
' Copyright : The following may be altered and reused as you wish so long as 
the
'             copyright notice is left unchanged (including Author, Website 
and
'             Copyright).  It may not be sold/resold or reposted on other 
sites (links
'             back to this site are allowed).
'
' Input Variables:
' ~~~~~~~~~~~~~~~~
' sDb        - Database Path & Name to execute command against
' sTableName - Name of the Table which has the field to switch
' sFieldName - Name of the field to switch to Memo Type
'
' Usage:
' ~~~~~~~~~~~~~~~~
' SwitchFieldType("D:\Contacts\Contacts.mdb", "tbl_Contact", "Notes")
'
' Revision History:
' Rev       Date(yyyy/mm/dd)        Description
' 
**************************************************************************************
' 1         2009-Mar-13                 Initial Release
'---------------------------------------------------------------------------------------
Function SwitchFieldType(sDb As String, sTableName As String, sFieldName As 
String)
On Error GoTo Error_Handler
    Dim db As DAO.Database
    Dim sSQL  As String
    
''Execute the query statement under DAO like this:
'DBEngine(0)(0).Execute sSQL, dbFailOnError
''or under ADO like this:
'CurrentProject.Connection.Execute sSQL
    
   Set db = DBEngine.Workspaces(0).OpenDatabase(sDb)    'External database
   'Set db = DBEngine(0)(0)                              ' Local database
   
   sSQL = "ALTER TABLE " & sTableName & " ALTER COLUMN " & sFieldName & " 
MEMO;"
   
   DoCmd.SetWarnings False
   db.Execute sSQL, dbFailOnError
   DoCmd.SetWarnings True
   
   Set db = Nothing

Exit Function

Error_Handler:
    MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf & 
"Error Number: " & _
    Err.Number & vbCrLf & "Error Source: SwitchFieldType" & vbCrLf & "Error 
Description: " & _
    Err.Description, vbCritical, "An Error has Occured!"
    Exit Function
End Function


Also, be careful as MEMO fields can hold a lot more data than text field, so 
you may loose data by doing what you are about to do.

Whatever you do, before proceeding, MAKE A BACKUP copy of your 
database(back-end of course)!!!  Better safe than sorry.
-- 
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.



"rscott927" wrote:

> I have to fields called 'NAME' and 'CLIENTID' in a table called 'LOCATIONS'. 
> They are in the Memo format  but need to be converted to text. How do I 
> change the format using VBA? In kow this has been asked in different way 
> before, but none of the other examples seem to help.
> Thank you so much for you help
0
Utf
12/8/2009 6:41:02 PM
Recommend you change the name of your [NAME] field to something else.  Name 
is a reserved word in Access and keeping it as a field name will 
occassionally result in interpretation errors.  You can avoid these errors by 
wrapping it in brackets [ ] every time you use it, but that can get annoying.

You can find a complete list of problem name and reserved words at:

http://www.allenbrowne.com/AppIssueBadWord.html#N

----
HTH
Dale



"rscott927" wrote:

> I have to fields called 'NAME' and 'CLIENTID' in a table called 'LOCATIONS'. 
> They are in the Memo format  but need to be converted to text. How do I 
> change the format using VBA? In kow this has been asked in different way 
> before, but none of the other examples seem to help.
> Thank you so much for you help
0
Utf
12/9/2009 9:17:06 PM
Reply:

Similar Artilces:

Import from Notepad delimited text
Is it possible to import from Notepad . There is a table with pipe delimiters that is automatically generated in a .dat text file using Notepad which I would like to import / link into my database daily. This .dat file arrives via email each day as an attachment. I tried saving the .dat file into a .txt extension but ACCESS wouldn't recognize it . I currently need to use the excel text wizard everyday to convert this file into an .xls format . I then have my access 2003 database linking to this ..xls file. Although I know how to convert this .dat file there are others ...

External data link change
Hi, I've a sheet linked to an external data on the net, and I would like that a cell in this sheet to indicate the last date and time it was updated, the simplest way the better but I can do some programming too. Thanks for your attention, -- Domingos Junqueira No need of help any more, I solved the question. Thanks again ...

Synchronize HQ data from SO
I curretly have 2 stores that usually receive inventory update from HQ. However during the last few weeks I had to data entry from each RMS clients (SO). Now I want to update inventory data at HQ using worksheet. But it seems not possible, although sales data show correctly. Is there any way ? -- Many Thanks In an HQ environment all new items must be entered from HQ and sent to stores. Did you create new items at store level ? You may want to create those items in HQ and send to store. Mihir Shah Diviasoft, Inc. www.diviasoft.com "cosamo" <cosamo@discussions.microsoft.c...

Is there a way to get the list command on the data toolbar?
I don't have list on my data toolbar. Is there a download for that or do I have to pay for it? I need it for a homework assignment. Thanks You need to use xl2003. That means you need to buy the newer version (or explain it to the instructor). Maybe he or she will let you slide on this section. cbuskirk20 wrote: > > I don't have list on my data toolbar. Is there a download for that or do I > have to pay for it? I need it for a homework assignment. > > Thanks -- Dave Peterson ...

Why does the change change to a number?
Hi all, I've noticed something wierd and always wondered WHY it happens. When you type a date into a cell, and then change the Formatting of it to a 'general' cell, it turns into a number. How does it come up with that number? What is the significance? i.e. type today's date of "12/7/2007" - change it to a 'General' format, and it then says "39423". I'm a trainer of Excel and this question always comes up. I'm curious myself too. Thanks! Joe It's the number of days since January zero 1900 using Excel default for windows (M...

changing the way Excel displays selected cells
Is there a way to change the way Excel displays selected cells? I'm interested in viewing all the selected cells highlighted (with light blue for instance), but by default excel highlights all the cells but not the first one the same occurs when you define a range with no adyacents cells Your definition of the display is not quite correct. Excel highlights the current cell, Excel also highlights a selecte range. The currently selected cell is generally the first of a range, bu press enter and the current cell changes and becomes the second, the third etc in the range. You cannot...

Track Changes
How do i remove the track changes in outlook? When i press "Enter", a symbol that represents "Enter" will appears. Same for space etc. ...

DST changes for Exchange 5.5
I noticed the 2007 DST Calendar Update "Exchange tool" is available now: http://support.microsoft.com/kb/930879 This will seemingly take care of calendars for mailboxes still on Exchange 5.5 servers, as Exchange 5.5 is listed as "compatible" . However would this address the CDO issues such as BlackBerry users and OWA users still on Exchange 5.5 ? Thanks in advance, Itrcb4 On Mon, 12 Feb 2007 14:31:00 -0800, itrcb4 <itrcb4@discussions.microsoft.com> wrote: >I noticed the 2007 DST Calendar Update "Exchange tool" is available now: > >http://su...

more on VBA function name change
I thought I'd start a new thread since I haven't received any replies to my first one... To recap: I've declared a function in a module using mixed case: Function TMDE_Category (FormName As Form) I noticed recently that it appeared in the module as Function tmde_category(FormName As Form) I changed it back to the mixed case declaration, saved the module, exited the app, reopened it and looked. The function had changed back to the all lowercase declaration. Things I've tried since the original post: Using the databse documenter, I selected all ob...

Can't Publish changes with Deploy Manager
After a migration process, I can't publish the changes made on CRM. When I try do this in Deploy Manager I get the follow error: ---------------------------------------------------------------------------- ----- Publish done with errors. See the event log to get deitails NETRA-INOVACAO: ***Error*** Failed to download XSL template files from Web Server ---------------------------------------------------------------------------- ----- Can somebody help me? I don't know if the migration process have any relationship with the error. Thank you for pay attention. []'s Vin´┐Żcius Pitta...

How to change icon for my application
Hi, I am currently developing an application on visual studio 6.0, and i wish to change the MFC icon on my application header. Anyone can help? Thank you. Raed Sawalha wrote: > Hi, I am currently developing an application on visual studio 6.0, and i > wish to change the MFC icon on my application header. Anyone can help? Thank > you. > > Open the icon resource for editing by double clicking. Then notice the control just above the editing grid that lets you switch between editing the large icon and editing the small one. -- Scott McPhillips [VC++ MVP] thanx that work...

Border with text
I'm trying to make a border using text. I want to repeat the same phrase over and over again. Idealy, I'd like the words to make a rectangular border for a sign... and when it hit the corner of the page, the phrase would continue down the next angle, and so on, until it made a box. Does anyone have any ideas on how to do this? WordArt would be your only option. If you had a draw program... Serif has a free draw application. http://www.freeserifsoftware.com/ OpenOffice is free and has a draw feature. www.openoffice.org I have a method using WordArt on my web site that might be...

How to change newsgroup message font
Like many other ribbon based programs I sometimes struggle to find how to make a change. This time its how to change the font just for newsgroup messages? regards "nobody" wrote in message news:EWTao.39493$GF5.7129@hurricane... > Like many other ribbon based programs I sometimes struggle to find how to make a change. This time its how to change the font just for newsgroup messages? Newsgroup messages are usually plain text. The font used is that selected at [no name tab] > Options > Mail > Read > Fonts for the encoding specified for the messag...

Notify change of email address when changing ISP
How do I notify my entire address book of an email address when I change ISP's? Thanks By sending a mail to everyone ? If you do so, please use BCC for the adresses, this way you won't spread everybody's e-mail adres to everybody. Niels Bob Baker wrote: > How do I notify my entire address book of an email address when I change ISP's? > Thanks ...

CRM data migration 10-13-04
Is there an easy way to migrate data from one CRM server to another? I have looked through the Data Migration toolkit, but it seems to be geared more towards migrating Goldmine/Act/etc to CRM, by populating the cdf tables "manually". Thanks, Matt Matt wrote: > Is there an easy way to migrate data from one CRM server to another? > > I have looked through the Data Migration toolkit, but it seems to be geared > more towards migrating Goldmine/Act/etc to CRM, by populating the cdf tables > "manually". > > Thanks, > Matt You need to use Redeployme...

How do I replace the last entire word in text cells?
I understand the REPLACE command but it seems restricted to characters or bytes. I this case, I want to replace the last word in all cells but the word is always different (ie. varying number of characters). Thanks in advance! Array entered (CTRL+SHIFT+ENTER), this will work: =LEFT(A1,LEN(A1)-MATCH(" ",MID(A1,LEN(A1)-ROW(INDIRECT("1:"&LEN(A1)))+1,1),0)) Change the reference to A1 to which ever cell you want. -- Regards, Dave "George" wrote: > I understand the REPLACE command but it seems restricted to characters or > bytes. I this case, I wan...

Pivot Table showing wrong data
I have a table with information such as Salesperson, Customer, Sales $, Year, Month, Date_Customer_Started. The data contains info for 2009 and 2010. I am trying to determine for every new account created in 2009 and 2010, Sales by new customer and salesperson. The Pivot table has sales data and count of customers by year and the rows contain Salesperson, Customer, Month and date_Customer_started. I expect if a customer started in April 2009, and the customer continuing to buy in 2010, sales figures by year and month and the count of customer only in 2009. But the pivot table sh...

Change a formula to an acual number
I want to change the formula I have created to the number it has created Example: Cell A1 is the number 1. Cell A2 is the formula =a1+1 creatin the number 2. I want this to be a two not a formula. Any ideas? Laura, copy, then paste special, valves -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so others can benefit from it Feedback on answers is always appreciated! Using Excel 2000 & 97 ** remove news from my email address to reply by email ** "Laura" <anonymous@discussions.microsoft.com> wrote in message news...

how do i chart the data below
AAA ABB ACC 3/17/2006 4607 653 599 3/18/2006 4461 754 650 3/19/2006 2167 707 527 3/20/2006 4329 568 722 3/21/2006 4379 2302 842 3/22/2006 10156 1983 1027 3/23/2006 5338 1839 870 i want to show how the values AAA... are being used over the given dates Charter_SKR The easiest and quickest is to select your data range, press F11. This will generate a chart sheet. You can format,change chart type etc as you need. ...Kelly koday@processtends.com "charter_SKR" <charterSKR@discussions.microsoft.com> wrote in message news:6933B9D0-B6AC-48A3-80FF-C8D68B57B8C6@microsoft.com....

Convert Quicken Deluxe 2000 data to Money 2004
Got fed up with Intuit products. Got new computer & backed up Quicken Deluxe 2000 data to floppy disk. Will Quicken 2000 convert to Money 2004 ? The Money 2004 package does not show Quicken Deluxe 2000 Thanks Yes, Money should convert the account data in your Quicken file. -- Will you sponsor me in the Tour de Cure? http://main.diabetes.org/site/TR?pg=personal&fr_id=1058&px=1626087 "jy" <jy24165@earthlink.net> wrote in message news:04f901c35fa8$b971e720$a001280a@phx.gbl... > Got fed up with Intuit products. Got new computer & > backed up Quicken Del...

Prohibiting edits to data in a text box
This seems like it should be simple: Using a form property sheet Access allows me to specify "Allow Edits", "Allow Additions", and "Allow Deletions", but these pertain to entire records. I can't figure out how to "Allow Additions" and not "Allow Edits" to just one specific control on my form. If I use the "Lock" feature then the user can't populate the field of a new record. Any tips? -mjg In the forms current event If Me.NewRecord Then Me.ControlName.Locked = False Else Me.ControlName.Locked = True End...

Problem Changing an Investment Name
I am trying to change an investment name and Money 2006 tells me "The name or symbol 'TRP Spectrum Income' has already been used for a deleted investment. Please enter a different name." When I go to delete investments the name does not appear! Any ideas on how I get Money to accept the name change? This is the first time I have run into this situation and I have made numerous name changes in Money over the years. In microsoft.public.money, Ken wrote: >I am trying to change an investment name and Money 2006 tells me "The name >or symbol 'TRP Spec...

Transferring data IN VBA between workbooks
I need to transfer a range of cells for every row one by one from one file File1.xls to a second file File2.xls from within a VBA program. I had it running where it coded a cut and paste but the program runs for 3 hours and If I tried to do anything else where I cut and paste I would get data from my running program when I tried to paste. Is there any way I can do this other than cut and paste ? Dennis I foud out what I was doing wrong I had this Range("A1") = Range("A1:P1") which will work in a single workbook but to a separate workbook you have to put Range("...

Should I change this code?
Should I change 556 to 560???..............Thanks for your help..........Bob Private Sub Command560_Click() On Error GoTo Err_Command556_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "frmClientInfomation" DoCmd.OpenForm stDocName, , , stLinkCriteria Exit_Command556_Click: Exit Sub Err_Command556_Click: MsgBox Err.Description Resume Exit_Command556_Click End Sub On Sun, 15 Jul 2007 16:37:26 +1200, "Bob V" <rjvance@ihug.co.nz> wrote: > >Should I change 556 to 560???..............Thanks for your help.....

How to change default font in Outlook 2003
Can someone tell me how to change tthe default font in Outlook 2003 when composing a new email. It always comes up as Times New Roman. I remember somewhere that I specified that Outlook should use Word as the text editor and that seems to be the case. I have Arial as my default font in Word but this seems to make no difference when using Outlook. Hi, Please go to Tools > Setting > Mail Format > Stationery and Fonts > Fonts It's right there :) On 20 Nov 2005 06:28:45 -0800, amarsarit@gmail.com wrote: >Hi, >Please go to Tools > Setting > Mail Format > Statione...