Alignment of text (1 Viewer)

luzz

Registered User.
Local time
Yesterday, 20:26
Joined
Aug 23, 2017
Messages
346
Hi guys, how do i make alignment to my text in my access report?
Thank you
 

Attachments

  • alignment.png
    alignment.png
    2.1 KB · Views: 119

CJ_London

Super Moderator
Staff member
Local time
Today, 04:26
Joined
Feb 19, 2013
Messages
16,634
not at all clear from your attachment whether this one control or more or what you mean by alignment. Need more information to provide any sort of suggestion
 

luzz

Registered User.
Local time
Yesterday, 20:26
Joined
Aug 23, 2017
Messages
346
not at all clear from your attachment whether this one control or more or what you mean by alignment. Need more information to provide any sort of suggestion

As you can see from my previous image that i attached, the second line of
Please state... is not align with the first line. How can i make both line align?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 04:26
Joined
Feb 19, 2013
Messages
16,634
with no more information the best I can suggest is to set the control(s) alignment to right (or left) in control properties - or from the ribbon in design view under the format tab
 

luzz

Registered User.
Local time
Yesterday, 20:26
Joined
Aug 23, 2017
Messages
346
with no more information the best I can suggest is to set the control(s) alignment to right (or left) in control properties - or from the ribbon in design view under the format tab

I tried all, it does not seem to work.

Current issue:
Please state: TH-A160017656 GLA 000052861-00
TH-A160017721 GLA 000052860-00

What i want to solve is to have TH-A160017721 GLA 000052860-00 align with TH-A160017656 GLA 000052861-00 in my report
Please state: TH-A160017656 GLA 000052861-00
TH-A160017721 GLA 000052860-00
 

Minty

AWF VIP
Local time
Today, 04:26
Joined
Jul 26, 2013
Messages
10,371
You are not helping yourself here, and repeating the question without answering the basics won't help.

CJ asked you in the first instance, is this one textbox or four ? If it is one how are you creating it.
Show us the design view, if nothing else.
 

Mark_

Longboard on the internet
Local time
Yesterday, 20:26
Joined
Sep 12, 2017
Messages
2,111
When laying out your fields, check the following values on the property sheet - format;
Top
Left
Text Align

Top
is relevant to make sure that fields line up as you read across

Left is relevant to make sure they align vertically
Text Align is relevant when ensuring data within aligned fields actually aligns as you expect.

Also make sure your data does not have anything wonky in it that could be throwing off your display.
 

kevlray

Registered User.
Local time
Yesterday, 20:26
Joined
Apr 5, 2010
Messages
1,046
In the worst case manually set the x value and/or y value of each component. Tedious, but guaranteed to work.
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 23:26
Joined
Feb 19, 2002
Messages
43,368
In a plain text control, you do not have any options for aligning text except as it applies to the entire control. If you change the table to use rich text, you might be able to solve the problem since you will have formatting capability within the text box. No promises though since I've never tried to solve this problem. You would have trouble with word also unless you created "outdents" or whatever they're called where the first line of a paragraph starts at x and second and subsequent lines start at x + 10. You could only get that to work by knowing exactly where the text worked and how to fix the alignment.

Of course, normalizing your data solves all problems. Once you mush multiple values into a single field, you cause nothing but trouble for yourself.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 22:26
Joined
Feb 28, 2001
Messages
27,228
You are not following what we are asking.

You show two values that are clearly of type String (or Text), each of which begins with TH. You want them to align. If this is a pair of text boxes, you need to set the alignment properties on EACH box. If this is NOT a pair of text boxes, then what is it?
 

luzz

Registered User.
Local time
Yesterday, 20:26
Joined
Aug 23, 2017
Messages
346
You are not helping yourself here, and repeating the question without answering the basics won't help.

CJ asked you in the first instance, is this one textbox or four ? If it is one how are you creating it.
Show us the design view, if nothing else.

I only have textbox to display my remarks
 

Attachments

  • remarkstextbox.png
    remarkstextbox.png
    2.4 KB · Views: 100

luzz

Registered User.
Local time
Yesterday, 20:26
Joined
Aug 23, 2017
Messages
346
You are not following what we are asking.

You show two values that are clearly of type String (or Text), each of which begins with TH. You want them to align. If this is a pair of text boxes, you need to set the alignment properties on EACH box. If this is NOT a pair of text boxes, then what is it?

Is a single textbox
 

Attachments

  • remarkstextbox.png
    remarkstextbox.png
    2.4 KB · Views: 67

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 22:26
Joined
Feb 28, 2001
Messages
27,228
OK, if that is a single text box, then the reason it doesn't align is because you have spaces between the elements.

I don't know how you put them there, but you might make this box get loaded by concatenation of the trimmed versions of the two strings.

Code:
    [Remarks] = Trim$( FirstString ) & vbCRLF & Trim$ (SecondString )

If the value in the [Remarks] box comes from a specific record, then the problem was introduced when that record was loaded.
 

JHB

Have been here a while
Local time
Today, 05:26
Joined
Jun 17, 2012
Messages
7,732
If the text in the table shows like you want it, then have you change the property "Text Format" for the control in the report from "Plain text" to "Rich text"?
The interesting thing is not the text you can see, but the characters that are invisible, such as Tabs, Spaces, Return, etc.
It requires you to write some code that analyses the text characters one at a time using their ASCII value.
I you don't know how to do it, post some data in MS-Access database.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:26
Joined
May 7, 2009
Messages
19,247
Does it always start with TH or first two letters?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:26
Joined
May 7, 2009
Messages
19,247
we can use Split() to check for the first
letter of your Textbox.

but i'll assume that the first two characters
are unique in your textbox.

copy the code in a Standard Module.

bring your report in design view.
select the Textbox you want to align
on it's Property->Other-Name, rename
the textbox other than the name of the
field (eg, txtBatchNo).

still on Property->Data, replace the
Control Source to:

=LeftAligned([theFieldName], 2)

Code:
Public Function LeftAligned(varField As Variant, NumberOfPrefix As Integer) As String
    Dim Splits As Variant
    Dim Positions() As Integer
    Dim CurrentPosition As Integer
    Dim FirstTwo As String
    Dim Counter As Integer
    Dim ReturnString As String
    varField = Trim(varField & "")
    If Len(varField) = 0 Then Exit Function
    Counter = 1
    FirstTwo = Left(varField, NumberOfPrefix)
    CurrentPosition = InStr(varField, FirstTwo)
    While CurrentPosition <> 0
        ReDim Preserve Positions(1 To Counter)
        Positions(Counter) = CurrentPosition
        CurrentPosition = InStr(CurrentPosition + NumberOfPrefix, varField, FirstTwo)
    Wend
    If UBound(Positions) = 1 Then
        ReturnString = varField
    Else
        For Counter = LBound(Positions) To UBound(Positions)
            If Counter <> UBound(Positions) Then
                ReturnString = ReturnString & Trim(Mid(varField, Positions(Counter), _
                                    Positions(Counter + 1) - Positions(Counter))) & vbCrLf
            Else
                ReturnString = ReturnString & Trim(Mid(varField, Positions(Counter)))
            End If
        Next
    End If
    LeftAligned = ReturnString
End Function
 

luzz

Registered User.
Local time
Yesterday, 20:26
Joined
Aug 23, 2017
Messages
346
OK, if that is a single text box, then the reason it doesn't align is because you have spaces between the elements.

I don't know how you put them there, but you might make this box get loaded by concatenation of the trimmed versions of the two strings.

Code:
    [Remarks] = Trim$( FirstString ) & vbCRLF & Trim$ (SecondString )

If the value in the [Remarks] box comes from a specific record, then the problem was introduced when that record was loaded.

Yes, my remarks is retrieve from my database
 

luzz

Registered User.
Local time
Yesterday, 20:26
Joined
Aug 23, 2017
Messages
346
we can use Split() to check for the first
letter of your Textbox.

but i'll assume that the first two characters
are unique in your textbox.

copy the code in a Standard Module.

bring your report in design view.
select the Textbox you want to align
on it's Property->Other-Name, rename
the textbox other than the name of the
field (eg, txtBatchNo).

still on Property->Data, replace the
Control Source to:

=LeftAligned([theFieldName], 2)

Code:
Public Function LeftAligned(varField As Variant, NumberOfPrefix As Integer) As String
    Dim Splits As Variant
    Dim Positions() As Integer
    Dim CurrentPosition As Integer
    Dim FirstTwo As String
    Dim Counter As Integer
    Dim ReturnString As String
    varField = Trim(varField & "")
    If Len(varField) = 0 Then Exit Function
    Counter = 1
    FirstTwo = Left(varField, NumberOfPrefix)
    CurrentPosition = InStr(varField, FirstTwo)
    While CurrentPosition <> 0
        ReDim Preserve Positions(1 To Counter)
        Positions(Counter) = CurrentPosition
        CurrentPosition = InStr(CurrentPosition + NumberOfPrefix, varField, FirstTwo)
    Wend
    If UBound(Positions) = 1 Then
        ReturnString = varField
    Else
        For Counter = LBound(Positions) To UBound(Positions)
            If Counter <> UBound(Positions) Then
                ReturnString = ReturnString & Trim(Mid(varField, Positions(Counter), _
                                    Positions(Counter + 1) - Positions(Counter))) & vbCrLf
            Else
                ReturnString = ReturnString & Trim(Mid(varField, Positions(Counter)))
            End If
        Next
    End If
    LeftAligned = ReturnString
End Function

Hi, i try your code and it prompt me error
 

Attachments

  • error.png
    error.png
    13.7 KB · Views: 49
  • error on code.png
    error on code.png
    13.7 KB · Views: 51

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:26
Joined
May 7, 2009
Messages
19,247
did you rename the Textbox Control?
rename it to something Other than
the FieldName on your table.
(Property->Other->Name)

also i gave you this:

=LeftAligned([theFieldName], 2)

replace [theFieldName] with the
fieldname on your table.
 

Users who are viewing this thread

Top Bottom