【发布时间】:2018-01-29 18:29:42
【问题描述】:
我在 MS ACCESS 的表格中有很长的文本字段。我需要为字段中的特定文本加下划线。我试图在设计视图中将文本格式更改为富文本,但我得到:
错误:此类对象不支持操作
在表中我有 320 行。我需要在 N.J.S.A 下划线。仅在长文本中。
请帮助我解决这个问题。提前致谢
【问题讨论】:
标签: ms-access-2013
我在 MS ACCESS 的表格中有很长的文本字段。我需要为字段中的特定文本加下划线。我试图在设计视图中将文本格式更改为富文本,但我得到:
错误:此类对象不支持操作
在表中我有 320 行。我需要在 N.J.S.A 下划线。仅在长文本中。
请帮助我解决这个问题。提前致谢
【问题讨论】:
标签: ms-access-2013
嗯...您必须将该字段属性从纯文本更改为富文本才能使其正常工作,并且设计视图应处理此问题。如果没有,请尝试以下代码。
Public Sub TestUnderline()
Dim db As DAO.Database
Dim tbl As DAO.TableDef
Dim fld As Field
Dim rst As DAO.Recordset
Dim strSQL As String
Dim strString As String
Set db = CurrentDb
Set tbl = db.TableDefs("Table1") 'Change to your table name
Set fld = tbl.Fields("TestField") 'Change to your field name
With fld.Properties("TextFormat")
If .Value = acTextFormatPlain Then
.Value = acTextFormatHTMLRichText
End If
End With
strSQL = "SELECT TestField " & _ 'Change to your Field name
"FROM Table1;" 'Change to your table name
Set rst = db.OpenRecordset(strSQL)
Do While Not rst.EOF
If InStr(1, rst![TestField], "N.J.S.A") Then 'Change to your field name
strString = Replace(rst![TestField], "N.J.S.A", "<u>N.J.S.A</u>") 'Change to your field name
rst.Edit
rst![TestField] = strString 'Change to your field name
rst.Update
End If
rst.MoveNext
Loop
EndCode:
If Not rst Is Nothing Then
rst.Close
Set rst = Nothing
End If
If Not tbl Is Nothing Then
Set tbl = Nothing
End If
If Not db Is Nothing Then
Set db = Nothing
End If
End Sub
学分给: How to convert a text field in an Access table to a rich text memo using VBA
【讨论】: