Storing Rich Text in a database
I want to store extracts from a web page or HTML-formatted email into my userform control (Rich Text Box) and then store the data into an Access database keeping the formatting. I've used a Memo field in the database.
Is this the correct way to do it?
Re: Storing Rich Text in a database
Memo field wouldn't save any formating at all. What you need is OLE object type field so you can save entire file but you will need to create rtf file first.
Search forum for saving files in database.
Re: Storing Rich Text in a database
You could use a memo field if you save the RTF formatted string to it. To get the RTF string from a RichTextBox use the TextRTF property instead of the regular Text property.
Re: Storing Rich Text in a database
Quote:
Originally Posted by RhinoBull
Memo field wouldn't save any formating at all. What you need is OLE object type field so you can save entire file but you will need to create rtf file first.
Search forum for saving files in database.
Had a look but couldn't find much on how to save the RTB dat to an RTF file then load it into Access. Have u got a link to sample code which could help me?
JA. Thanks for that. I'll give that a go too.
Re: Storing Rich Text in a database
Quote:
You could use a memo field if you save the RTF formatted string to it. To get the RTF string from a RichTextBox use the TextRTF property instead of the regular Text property.
Just do....
VB Code:
RS!Blob = RichTextBoxReference.TextRTF
The blob holds the complete rich text box text plus formatting.
.
Re: Storing Rich Text in a database
Quote:
Originally Posted by David.Poundall
Just do....
VB Code:
RS!Blob = RichTextBoxReference.TextRTF
The blob holds the complete rich text box text plus formatting.
Thnx David. What's a "blob"? How is it setup in an Access table?
Re: Storing Rich Text in a database
The binary field that holds files or images, or in your case, Richtext.
Substitute your fieldname, which you declare as a BLOB type.
Re: Storing Rich Text in a database
Actually, you don't need to use a Blob (and shouldn't in this case). Since the RTF text is nothing but a text you can use a memo field.
Re: Storing Rich Text in a database
So do you think I can paste parts of a web page into a RTB exactly as it's displayed in MSIE and then have that saved to a memo field to be later displayed in all its original glory?? :confused:
Re: Storing Rich Text in a database
I think so, I have looked at RTF of my page, and it is viewable in Wordpad. In notepad, it is just text, except the inline image, which is binary.
Re: Storing Rich Text in a database
Quote:
Originally Posted by Joacim Andersson
Actually, you don't need to use a Blob (and shouldn't in this case). Since the RTF text is nothing but a text you can use a memo field.
Sorry - I name the fields as Blobs but you are quite correct - specifically the record is stored in a memo field. Apologies if it misled you Thief
:thumb:
Re: Storing Rich Text in a database
Quote:
Originally Posted by Thief_
So do you think I can paste parts of a web page into a RTB exactly as it's displayed in MSIE and then have that saved to a memo field to be later displayed in all its original glory?? :confused:
If it is viewable in the RTB then you can save it. If you have images in there it may start to take up a lot of space in your databse though.
Re: Storing Rich Text in a database
I've just checked how an RTB works with web page data, and it works, but it sucks more than anything when it comes to formatting.
I suppose what I need is some sort of web control which accepts the copy-paste off a web page, stores the info as HTML and when displayed, acts sorta like a web browser control.
Is there such a thing and if so, is there some sample code to show how it works?
Re: Storing Rich Text in a database
No - afraid not. What's the background to what you are trying to do. Is it a project need or wishfull thinking?
Re: Storing Rich Text in a database
Thanks David.
I'm the admin for a Message Handling System for the company. One of my roles is to develop a Knowledge Base of the errors we receive from the MHS system and document the fix.
The errors are presented to me via a web browser.
My aim is to copy a part of the web browser screen to the KB app then type in the resolution so that others can see how to fix the same problem in the future when new versions are distributed and similar problems arise.
Re: Storing Rich Text in a database
maybe convert it to xml? except that it would strip out the formatting.
Re: Storing Rich Text in a database
Quote:
Originally Posted by RhinoBull
Memo field wouldn't save any formating at all. What you need is OLE object type field so you can save entire file but you will need to create rtf file first.
Search forum for saving files in database.
As I said: best bet is to save entire file ...
Take a look at this sample - it stores image file but logic would be the same:
http://www.vb-helper.com/howto_database_picture.html
Re: Storing Rich Text in a database
Thanks Rhino,
How would I get the web-based data onto a control on a userform? What control will accept pasted (formatted) data?