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

Changing the text/highlight color in a bound textbox

I have a datasheet style form with textbox (MyTextBox) that has the Text Format property set to "Rich Text". It is bound to a memo field in a table. How do I change the text or highlight color of certain text in the textbox such that the formating is saved in an underlying memo field?

My situation is a little different than other posts I read. Most posts show how to find and select certain text in a textbox, and then change the formating of the control (textbox). Since the form is a datasheet style form, changing the formating of the control will change the formating for that field in all records! I want to change the formating of the text IN the textbox so that the formating is captured in the memo field for an individual record. Make sense?

I've figured out how to find the records, fields, and text that I want to modify, but I'm missing the line of code that modifies text formating. Here's a sample of what I have:

Expand|Select|Wrap|Line Numbers
  1. Me.MyTextBox.SetFocus
  2. Me.MyTextBox.SetFocus.SelStart = 0
  3. Me.MyTextBox.SetFocus.SelLength = Len(MyRichTextBox.Value)
What comes next? I've searched through all of the DoCmd.RunCommand's and I can't find one that changes the text color or highlight color.

Any help is greatly appreciated.
Jun 19 '09 #1
7 14994
mshmyob
904 Expert 512MB
Hello Sphinney,

When you say a datasheet view are you talking about a subform?

What is your criteria to determine the change in colour of the memo field?

Do you actually want the Memo field to save the colour codes permanently or just appear to change colours on the form? (I could do either for you)

Is this Access 2007?

cheers,

@sphinney
Jun 22 '09 #2
Hi mshmyob,

Thanks for replying to my post. My form is a subform with the Default View property set to "Datasheet" (no other views are allowed). The form only contains a few textboxes that are bound to memo fields in "MyTable". The textboxes have the Text Format property set to "Rich Text". This is an Access 2007 database (i.e. *.accdb).

I did not include information about criteria in my original post because I thought it was extemporaneous to my primary question and I didn't want to burden folks with unnecessary details. But in answer to your question (at least partly) my application reads text out of a Microsoft Word 2007 file. It then looks for matching text in the memo fields in MyTable.

If matching text is found in MyTable, I want to permanently change the text and background color in the memo field (and not just temporarily display it). I couldn't figure out how to modify the formating of the text by accessing the memo fields in MyTable directly via a DAO recordset. So, instead, I bound the memo fields to textboxes on a form and am trying to modifiy the text and background color in the textboxes, then update MyTable.

It seems like it should be so easy.
1. Set focus to a particular textbox
2. Set the selection start position (based on the text I'm looking for)
3. Set the selection length (based on the text I'm looking for)
4. Change the text/background color
5. Update the data back to MyTable

I just can't figure out the VB code for item 4.

Thanks for your help!

@mshmyob
Jun 22 '09 #3
mshmyob
904 Expert 512MB
OK I will see what I can throw together for you in the morning. Just got home and pretty tired now.

cheers,

@sphinney
Jun 23 '09 #4
No problem. I'm just appreciative of any assistance/guidance your able to give.

@mshmyob
Jun 23 '09 #5
mshmyob
904 Expert 512MB
Sorry for the delay but have been very busy.

Here is a demo to try. See if this helpss and is of any use to you. Let me know and I can answer any questions or make any changes.

It demonstrates how to search for a string and replace it and then update the memo field using HTML coding and displays it in a subform datasheet view. This works only in AC2007 since it uses the new RTF properties of fields/controls.


cheers,
Attached Files
File Type: zip rtf_demo.zip (110.9 KB, 1177 views)
Jun 24 '09 #6
mshmyob,

Thanks for the sample file & code! I was successfully able to use the <font color =...> tag to change the font color. I also included a <p style="background-color:.."> tag to alter the highlight color (as it turns out, one must use the font tag first before the paragraph tag).

You helped me do exactly what I wanted to do! I'm most greateful. On my own I was headed down an entirely different (and wrong) path.

Many thanks,

@mshmyob
Jun 26 '09 #7
mshmyob
904 Expert 512MB
You're welcome sphinney - good luck with your project.

cheers,

@sphinney
Jun 26 '09 #8

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

Similar topics

1
by: Charles A. Lackman | last post by:
Hello, Looking for help changing the Highlight color in a Textbox in VB.NET. Any Suggestions will be greatly appreciated. Thanks, Chuck
2
by: WhiskyRomeo | last post by:
I have a bound textbox (bindings are set at design time) to a dataset column. Sometimes the value of this textbox must be set so that the underlying database field gets updated to null when using...
5
by: MLH | last post by:
This property is only available only when the control has the focus... Error #2185 I get the above error when code running in FormA is trying to set the value of a hidden textbox on FormB to a...
2
by: | last post by:
Hi all, I need to format screen output for a textbox that's bound to a datasource. I know how to format the data in a plain old string, but in this case I'm not sure where to "sneak" in there...
1
by: Rich | last post by:
Hello, I have some datefields in a dataset (ds1). I bind some textbox controls on a windows form to these date fields in ds1, but I only want to see 01/01/2004 instead of 1/1/2004 8:00:00 AM. ...
7
by: Howard Minor | last post by:
Not sure why this is an issue, but apparently when you paste a string into a textbox that is bound to a dataset/datasource, it does not save into the dataset. I've tried several things including...
1
by: John | last post by:
Hi, When a textbox gets focus in WinForm, the text inside the textbox is highlighted with default color. How can I get the value of the default highlight color like the following? Dim...
14
by: > Adrian | last post by:
Is there a way of stopping text from highlighting in textbox? Many thanks, Adrian.
0
nicebasic
by: nicebasic | last post by:
I'm writing a program that uses a RichTextBox. Since the Black Highlight Color is not readable in some cases, I need to change it at some times. I need another Selection or Highlight Color like...
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
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.