473,396 Members | 1,940 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,396 software developers and data experts.

Mixing Formats within a textbox - revisited - Lebans

I am using Lebans lady example to mix Bold and Normal in a single line text box, I have altered it and I still cant get it to bold the text I need bolded I have pasted it here, can somebody help? I need Last_Name, Suff, First_Name, Middle_Name bolded, the rest normal. Thanks Melissa


' **START CODE
' Written by Stephen Lebans 1999
' Stephen@lebans.com
' www.lebans.com

' This sample database is for a Poster named "Lady".
' She wanted to print her concatenated Control with
' one part in Bold and the rest normal.

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Const TWIPS = 1
Dim strLast_Name As String
Dim strSuff As String
Dim strFirst_Name As String
Dim strMiddle_Name As String
Dim strCompany As String
Dim strAddress_1 As String
Dim strCity As String
Dim strZip As String
Dim strWork_Phone As String
Dim strSpecialty_1 As String
Dim intPosition As Integer
Dim CtlDetail As Control
Dim intMargin As Integer

' I'll leave in Italic and Color
' in case you want to use these
Dim oldFontBold As Integer
Dim oldFontItalic As Integer
Dim oldForeColor As Long
Dim oldFontName As String
Dim oldfontsize As Integer
Dim oldScaleMode As Integer

'Save current Font settings
With Me
oldFontItalic = .FontItalic
oldFontBold = .FontBold
oldForeColor = .ForeColor
oldFontName = .FontName
oldfontsize = .fontsize

oldScaleMode = .ScaleMode
End With



' Remember for this sample I am
' naming your control tblady. You MUST
' change the name here to match that of the actual control. Also
' I assumed the control source is exactly as you posted to the NG
' =[LastName]&", "&[FirstName]
' OK lets find your control and seperate
' the concatenated field.
' for each control in details control
For Each CtlDetail In Me.Section(acDetail).Controls
If CtlDetail.Name = "text3" Then
With CtlDetail
.Visible = False
intPosition = InStr(1, .Value, ",")
strLast_Name = Left(.Value, intPosition - 1)
strSuff = Mid(.Value, intPosition + 2)
strFirst_Name = Mid(.Value, intPosition + 2)
strMiddle_Name = Mid(.Value, intPosition + 2)
strCompany = Mid(.Value, intPosition + 2)
strAddress_1 = Mid(.Value, intPosition + 2)
strCity = Mid(.Value, intPosition + 2)
strZip = Mid(.Value, intPosition + 2)
strWork_Phone = Mid(.Value, intPosition + 2)
strSpecialty_1 = Mid(.Value, intPosition + 2)

'Debug.Print strLast
'Debug.Print strFirst

End With

With Me
' Make sure we are in Twips
.ScaleMode = TWIPS

' Grab Controls current Font settings
.FontName = CtlDetail.FontName
.fontsize = CtlDetail.fontsize

' Create desired Font settings
' for the Last Name - Bold Text
.FontBold = True
'.FontItalic = True
'.ForeColor = RGB(255, 0, 0) 'RED
.CurrentX = CtlDetail.Left
.CurrentY = CtlDetail.Top
' For some reason must be Me.Print not .Print
Me.Print strLast_Name;
Me.Print ", ";
Me.Print strSuff;
Me.Print ", ";
Me.Print strFirst_Name;
Me.Print ", ";
Me.Print strMiddle_Name;
Me.Print ", ";
' Reset Font-> NO Bold for FirstName
.FontBold = False
'.FontItalic = False
Me.Print strCompany;
Me.Print ", ";
Me.Print strAddress_1;
Me.Print ", ";
Me.Print strCity;
Me.Print ", ";
Me.Print strZip;
Me.Print ", ";
Me.Print strWork_Phone;
Me.Print ", ";
Me.Print strSpecialty_1;


' Restore Reports original Font settings
.ScaleMode = oldScaleMode
.FontBold = oldFontBold
.FontItalic = oldFontItalic
.FontName = oldFontName
.fontsize = oldfontsize
.ForeColor = oldForeColor

End With


End If
Next

' Cleanup
Set CtlDetail = Nothing
End Sub
Mar 23 '07 #1
4 2192
nico5038
3,080 Expert 2GB
The standard Access textbox won't support differences in bold/italics/etc.
Did you try the rich text control:
http://www.lebans.com/richtext.htm

Nic;o)
Mar 24 '07 #2
Yes the code I posted above IS from Lebans "Lady" example and works perfectly - however I have several concatenated fields and I need the first four bolded not just the first as in Lebans code - I messed around with it to see if I could get it to work but the best I could do caused all my fields to be bolded.
Mar 26 '07 #3
nico5038
3,080 Expert 2GB
Yes the code I posted above IS from Lebans "Lady" example and works perfectly - however I have several concatenated fields and I need the first four bolded not just the first as in Lebans code - I messed around with it to see if I could get it to work but the best I could do caused all my fields to be bolded.
Hmm, The line:

.FontBold = False

Should be the "border" between bold and not bold.
Just make sure that the control (textbox?) used is a copy of the working field and has the correct name.

Nic;o)
Mar 26 '07 #4
Thanks, I have checked what you suggestd and verified the name of my textbox. I think it has something to do with the placement of the fields themselves in this part of the code:

Expand|Select|Wrap|Line Numbers
  1.  With CtlDetail
  2.             .Visible = False
  3.             intPosition = InStr(1, .Value, ",")
  4.             strLast_Name = Left(.Value, intPosition - 1)
  5.             strSuff = Mid(.Value, intPosition + 2)
  6.             strFirst_Name = Mid(.Value, intPosition + 2)
  7.             strMiddle_Name = Mid(.Value, intPosition + 2)
  8.             strCompany = Mid(.Value, intPosition + 2)
  9.             strAddress_1 = Mid(.Value, intPosition + 2)
  10.             strCity = Mid(.Value, intPosition + 2)
  11.             strZip = Mid(.Value, intPosition + 2)
  12.             strWork_Phone = Mid(.Value, intPosition + 2)
  13.             strSpecialty_1 = Mid(.Value, intPosition + 2)
  14.  
  15.             'Debug.Print strLast
  16.             'Debug.Print strFirst
  17.  
  18.         End With
Should the mid values above be changed? I experimented with that but I just couldn't seem to get it right.
Mar 26 '07 #5

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

Similar topics

8
by: Jude | last post by:
Hi all, I'm trying to mix bold and non-bold text within a textbox on a report. Has anyone out there ever figured out how? Thanks! Jude
2
by: Michael | last post by:
Hi ! I'm trying to 'alter' the access TextBox control to achieve the following; When the cursor is over the TextBox control I want to display a button to the right of the TextBox control...
7
by: Mark Thomas | last post by:
Delighted to find Lebans textbox justification but... ....after you have downloaded the sample database, with its module, what do you do to make your own text boxes in your own database have...
6
by: Oren | last post by:
Hi, Is there a way to use the SelStart functionality in a textbox that has more than 32,767 characters in it, when the cursor is beyond the 32,767th characterz? SelStart is an integer, and it...
1
by: mbberkowitz | last post by:
I should begin by thanking Mr. Lebans for all the helpful stuff he's posted on his site. I've incorporated code from his A2KLoadSaveJpegVer9.mdb into my database so that I could move jpegs...
4
by: MLH | last post by:
Setting form's Picture property to another file from within VBA doesn't repaint the form with new bitmap - for instance... Me.Picture = "c:\pics\MyNewPic.jpg" I tried Me.Repaint afterward,...
13
by: Randy Jackson | last post by:
Hello, I'm creating a sample portfolio application for MS-Access XP, and I'm wondering if there's a suitable replacement for the ms-access textbox control. I'm looking for something similar to...
3
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when...
7
by: robert.waters | last post by:
I have an Access database frontend linked via ODBC to a large (gigabytes) mysql database. I need to view a large amount of data in a a textbox (variable up to 300K), but I receive a 'there isnt...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.