连接富文本字段(HTML)并在Access表单上显示结果 [英] Concatenate Rich Text Fields (HTML) and display result on Access form

查看:297
本文介绍了连接富文本字段(HTML)并在Access表单上显示结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个访问数据库,该数据库处理的都是文字和物品。一篇文章由几个项目组成。每个项目都有一个富文本字段,我希望通过将所有项目的所有富文本字段连接起来来显示文章的文本内容。

I have an access database which deals with "articles" and "items" which are all textual stuff. An article is composed of several items. Each item has a rich text field and I wish to display the textual content of an article by concatenating all rich text fields of its items.

我编写了一个VBA程序串联项目富文本字段并将其馈送到表单上的独立TextBox控件中(Textbox.Text =结果字符串),但是它不起作用,我收到一条错误消息,提示此属性参数过长。
如果我尝试将单个文本字段输入到Textbox控件中,则会收到另一个错误,指出我无法理解,无法更新记录集,这是关于什么记录集的?

I have written a VBA program which concatenates the items rich text fields and feeds this into an independent TextBox control on my form (Textbox.Text = resulting string) but it does not work, I get an error message saying "this property parameter is too long". If I try to feed a single textual field into the Textbox control, I get another error stating "Impossible to update the recordset" which I do not understand, what recordset is this about ?

每个项目字段通常是这样的(我使用方括号而不是<和>,因为否则该帖子的显示不正确)[div] [font ...]内容[/ font] [/ div],还包括 [em]标签。

Each item field is typically something like this (I use square brackets instead of "<" and ">" because otherwise the display of the post is not right) [div][font ...]Content[/font] [/div]", with "[em]" tags also included.

在我的问题面前,我有很多问题:

In front of my problem, I have a number of questions :

1)您如何将HTML字符串输入到独立的Textbox控件中?

1) How do you feed an HTML string into an independent Textbox control ?

2)连接这些HTML字符串,还是应该修改标签,例如,只有一个 [div]块而不是连续几个(禁止中间div标签)?

2) Is it OK to concatenate these HTML strings or should I modify tags, for example have only one "[div]" block instead of several in a row (suppress intermediate div tags) ?

3 )我应该使用什么控件来显示结果?

3) What control should I use to display the result ?

您可能会回答说,我也可能会使用一个子表单来显示由文章组成的不同项目。是的,但是每个商品的高度都不可能变化,整篇文章的阅读非常繁琐

You might well answer that I might as well use a subform displaying the different items of which an article is made up. Yes, but it is impossible to have a variable height for each item, and the reading of the whole article is very cumbersome

感谢您提供的任何建议

Thank you for any advice you may provide

推荐答案

它对我有用,功能很简单:

It works for me with a simple function:

Public Function ConcatHtml()

    Dim RS As Recordset
    Dim S As String

    Set RS = CurrentDb.OpenRecordset("tRichtext")
    Do While Not RS.EOF
        ' Visually separate the records, it works with and without this line
        If S <> "" Then S = S & "<br>"

        S = S & RS!rText & vbCrLf
        RS.MoveNext
    Loop
    RS.Close

    ConcatHtml = S

End Function

和带有控件源 = ConcatHtml()的未绑定文本框。

and an unbound textbox with control source =ConcatHtml().

在您的情况下,您必须添加文章外键作为参数来限制您串联的项目记录。

In your case you'd have to add the article foreign key as parameter to limit the item records you concatenate.

这篇关于连接富文本字段(HTML)并在Access表单上显示结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆