Since Rich Text is not a datatype and is not a field property which can be defined or modified with a SQL statement, you will need VBA to set the field's TextFormat property.
You can adapt techniques from this code sample.
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Set db = CurrentDb
Set tdf = db.TableDefs("Table1")
Set fld = tdf.Fields("memo_fld")
Debug.Print "acTextFormatPlain: " & acTextFormatPlain & _
"; acTextFormatHTMLRichText: " & acTextFormatHTMLRichText
With fld.Properties("TextFormat")
Debug.Print "TextFormat: " & .Value
If .Value = acTextFormatPlain Then
.Value = acTextFormatHTMLRichText
Debug.Print "TextFormat changed to: " & .Value
End If
End With
Note that code is run from the database which contains the target table. If Table1
was actually a link to a table in another Access db file, the code would fail.
Note also that only applies to a memo field. The TextFormat property is not created for regular text datatype fields, so this will throw error #3270, "Property not found."
Debug.Print tdf.Fields("some_text").Properties("TextFormat").Value
Since you will be converting regular text fields to memo fields, that point is probably not a concern. I mentioned it only in case you stumble into it.
ColeValleyGirl discovered the TextFormat property is not always created for a new memo field.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…