473,320 Members | 2,027 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,320 software developers and data experts.

TableDef creation, Rich Text Field (Access 2007)

TheSmileyCoder
2,322 Expert Mod 2GB
I need to create a table, where one of the memo fields shall be a Rich Text field. Can anyone help me with that? This is the code I currently have.

Expand|Select|Wrap|Line Numbers
  1. Public Sub createConTable()
  2. 'Create the table for consequences
  3.  
  4.     Dim tblDef As TableDef
  5.     Set tblDef = CurrentDb.CreateTableDef(strConTable, , , CurrentProject.Connection)
  6.  
  7.     With tblDef
  8.         .Fields.Append .CreateField("KEY_Consequence", dbLong)
  9.         .Fields.Append .CreateField("ID_Hazard", dbLong)
  10.         .Fields.Append .CreateField("int_Number", dbInteger)
  11.         .Fields.Append .CreateField("mem_Consequence", dbMemo)
  12.         .Fields.Append .CreateField("mem_OLD_Consequence", dbMemo)
  13.         .Fields.Append .CreateField("mem_Compare_Consequence", dbMemo)
  14.  
  15.     End With
  16.  
  17.     CurrentDb.TableDefs.Append tblDef
  18.  
  19.  
  20. 'Cleanup
  21.     Set tblDef = Nothing
  22.  
  23. End Sub
I have tried such things as:
Expand|Select|Wrap|Line Numbers
  1. .Fields("mem_Compare_Consequence").Properties("TextFormat")="Rich Text"
without success.

Any help is greatly appreciated.
Jul 2 '10 #1

✓ answered by TheSmileyCoder

I found out what to do. The problem is that the property for textformat couldn't be found, unless I had manually created it first (by manually entering table design view and setting it to rich text). Whether this is because Access per default does not create the property, until it is used the first time, or if its because this local table, is generated from a linked access 2000 table in a Access.

Now this is what I did:
Expand|Select|Wrap|Line Numbers
  1. Dim prp as DAO.Property
  2. With myTDF.Fields("mem_Compare_Action")
  3.             Set prp = f.CreateProperty("TextFormat", dbByte, 1) '1=acTextFormatHTMLRichText, constant only known in AC2007
  4.             .Properties.Append prp
  5. End With

6 5993
NeoPa
32,556 Expert Mod 16PB
Is this something you've managed to do manually first Smiley? I have to say that, from my research (2003 only mind you), a Memo field takes plain text data only.
Jul 2 '10 #2
TheSmileyCoder
2,322 Expert Mod 2GB
Access 2007 has built in support for rich text field. A memo field can in that case be either "Plain Text" or "Rich Text". You can manually set the field in design view, but im not one for doing stuff manually :P
Jul 2 '10 #3
NeoPa
32,556 Expert Mod 16PB
I wouldn't suggest it :D

I was merely asking, as that is often a very good indicator of what is available to do via code.

I'm afraid this seems to be veering into 2007 specific territory, where I drown if I go in too far ;)
Jul 2 '10 #4
ADezii
8,834 Expert 8TB
Try:
Expand|Select|Wrap|Line Numbers
  1. .Fields("mem_Compare_Consequence").Properties("TextFormat")=1
Jul 2 '10 #5
TheSmileyCoder
2,322 Expert Mod 2GB
I found out what to do. The problem is that the property for textformat couldn't be found, unless I had manually created it first (by manually entering table design view and setting it to rich text). Whether this is because Access per default does not create the property, until it is used the first time, or if its because this local table, is generated from a linked access 2000 table in a Access.

Now this is what I did:
Expand|Select|Wrap|Line Numbers
  1. Dim prp as DAO.Property
  2. With myTDF.Fields("mem_Compare_Action")
  3.             Set prp = f.CreateProperty("TextFormat", dbByte, 1) '1=acTextFormatHTMLRichText, constant only known in AC2007
  4.             .Properties.Append prp
  5. End With
Sep 16 '10 #6
NeoPa
32,556 Expert Mod 16PB
Smiley:
Whether this is because Access per default does not create the property, until it is used the first time, or if its because this local table, is generated from a linked access 2000 table in a Access.
It's the former Smiley. I've come across something similar in the past where it was necessary to create and add the property (I forget which) to the object's collection before it could be accessed, so this is not unique in that respect. I believe it was for Unicode Compression of a text field in a table. I've only ever played in that sort of area once, but I remember it being very hard to work out what was going on and what was required to get past it.

Well done for solving anyway :)
Sep 16 '10 #7

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

Similar topics

3
by: Christoph | last post by:
Does anyone have any recommendations on a good (or, at least decent) and ideally free rich text field control written in javascript? We've been using the one that came with Micro- soft's...
1
by: PC User | last post by:
I found this Rich Text Editor and I've been trying to recreate it in my own application. I've had trouble with the COMCTL.ImageListCtrl and the COMCTL.Toolbar to recreate the toolbar. And I've...
5
by: Ira Solomon | last post by:
Hi: Any quick opinions on Access 2007? Has anyone got this to coexist with Access 2003? Thanks Ira
9
by: Neil | last post by:
I need to implement a rich text box in an MDB file for a user base that consists of Access 2000 and Access 2002. Unfortunately, I'm using Access 2003 on my development machine. My understanding is...
2
by: Brad Williams | last post by:
Greetings, I have a Access 2007 App and I want to have a Config File. I have several unbound Text Boxes that are in small Date format that will be used as a Filter for several forms. I would like...
5
by: ARC | last post by:
Just found out something interesting with Access 2007... In table design, if you set a memo field to the new rich text option, and put that control on a form, set the control to rich text, you can...
16
by: Neil | last post by:
I posted a few days ago that it seems to me that the Access 2007 rich text feature does not support: a) full text justification; b) programmatic manipulation. I was hoping that someone might...
2
LBryant
by: LBryant | last post by:
Is there any way, in Access 2003, to offer rich text input without modifying the registry. I'm in a corporate environment where that is not possible. When a RichText control is added to a form, I...
11
by: ARC | last post by:
Hello all, My app has an e-mailing feature where you can e-mail reports, as well as a bulk e-mail feature for e-mailing all customers (as separate e-mails). I allow the user to set the subject...
10
by: kujito | last post by:
Ok, here it goes. I got my queries straightened out and they return the data I want in the format I want(finally). The data are sorted alpha. descending by ProjectName. Each project has a unique...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.