Results 1 to 8 of 8
  1. #1
    Alex Motilal is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2008
    Location
    Coimbatore, India
    Posts
    192

    Formating string

    Hello everybody
    I have the following string in the Header section of the Report.
    =”Stock of Cotton Bales as of “&Format$([DateOfIssue],’mmmm dd, yyyy’)
    If the date is 12/ 2/10, the following heading is returned:
    Stock of Cotton Bales as of December 02, 2010
    I want the date portion in bold and underlined as follows:
    Stock of Cotton Bales as of December 02, 2010
    Can anyone please help what code should be added to accomplish this.


    With lots of thanks,
    Alex

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    As far as I know which is very limited Bold characters in between a Normal text box is not possible.

    the Font options available with a normal text Boxes are :

    Text1.FontName = "times new roman"
    Text1.FontUnderLine=True
    Text1.FontSize = 12
    Text1.FontBold = True
    Text1.ForeColor = vbRed

    But this is possible with Microsoft RichTextBox Control.

    here is an example:

    Assuming "Stock of Cotton Bales as of" this part of your title to be constant which comes to 28 Characters including spaces, I have used RTB.SelLength to Bold out the date and Underline it too. So instead of using a text box u can use a RichTextBox to display your title. Well u can combine values from control anyway you like.

    Dim strString As String
    strString = "Stock of Cotton Bales as of December 02, 2010"
    RTB.SelText = strString
    RTB.SelStart = 28
    RTB.SelLength = Len(strString) - 28
    RTB.SelBold = True
    RTB.SelUnderline = True
    RTB.SelStart = Len(RTB.Text)
    End Sub

    strString is used to set the Text of the RichTextBox which is named RBT.

    if this solves your problem mark the thread solved.

  3. #3
    Alex Motilal is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2008
    Location
    Coimbatore, India
    Posts
    192
    Thank You Maximus.
    I havnt tried yet. I'll inform the result soon.
    With regards,
    Alex

  4. #4
    Alex Motilal is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2008
    Location
    Coimbatore, India
    Posts
    192
    Dear Maximus,
    I was under the impression that only Memo fields can be formated. I am using Access 2007. Can u be more elaborate. Is there a separate control "Rich TextBox"? In which event the code should be written? In fact, the phrase =”Stock of Cotton Bales as of “&Format$(Forms![Dialog]![DateOfIssue],’mmmm dd, yyyy’) is in the control source of the Unbound Text Box in the header section of the Report. The Date part Format$(Forms![Dialog]![DateOfIssue],’mmmm dd, yyyy’) is from the Form 'Dialog' which gives the date criteria to generate the Report.
    Alex

  5. #5
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Microsoft Rich Textbox Control, Version 6.0 is an ActiveX Control. I tried out this sample in Access 2000. This control is Listed in the list of ActiveX Controls.

  6. #6
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    an alternate way: put "Stock of Cotton Bales as of" in textbox1 and "December 02, 2010" in textbox2, then format textbox2 as you want.

  7. #7
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    I have done a small sample here. I have two text boxes Text7 and Text9 on my start up form. Type Name in Text7 and DOB in Text9 and Click the command button.

    Example: Name=maximus DOB:09/04/1980

    Result appears in the RichTextBox RTB:

    My name is maximus. I was born in 09/04/1980

    This code can be used from Other events too with modifications.



    Dim strString As String
    Dim strString1 As String
    Dim strstring2 As String

    Me.RTB = ""

    If IsNull(Me.Text7) Then
    MsgBox "Type name"
    Exit Sub
    End If
    If IsNull(Me.Text9) Then
    MsgBox "Type DOB"
    Exit Sub
    End If


    strString1 = "My Name is " & Me.Text7
    strstring2 = ". I was born on " & Me.Text9
    strString = strString1 & strstring2



    Me.RTB.SelText = strString
    Me.RTB.SelStart = Len(strString1) + 2
    Me.RTB.SelLength = Len(strString) - Len(strString1)
    Me.RTB.SelBold = True
    Me.RTB.SelUnderline = True
    Me.RTB.SelStart = Len(RTB.Text)

    Me.Text7 = Null
    Me.Text9 = Null


    Refer to attached mdb file

  8. #8
    Alex Motilal is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2008
    Location
    Coimbatore, India
    Posts
    192
    Thanks. The solution worked.
    Alex

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Conditional Formating In A Report
    By cadsvc in forum Reports
    Replies: 11
    Last Post: 11-02-2010, 04:47 PM
  2. Conditional Formating in pivot table
    By Tina in forum Access
    Replies: 0
    Last Post: 08-25-2010, 10:38 AM
  3. Formating a query
    By lmp101010 in forum Queries
    Replies: 2
    Last Post: 08-17-2010, 05:26 PM
  4. Formating a control in MS Access Reports
    By Alex Motilal in forum Access
    Replies: 3
    Last Post: 11-15-2008, 09:09 PM
  5. Querry formating
    By Zoroxeus in forum Queries
    Replies: 0
    Last Post: 03-07-2006, 11:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums