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
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
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.
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?
[Remarks] = Trim$( FirstString ) & vbCRLF & Trim$ (SecondString )
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
Does it always start with TH or first two letters?
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.
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