Text Box Formatting - reporting-services

How do I display address values in one row in a Text Box?
Currently values are appear as multiple rows one under another for example:
5,Irivine Place
po box 2345
usa
I'm looking for something like:
5,Irivine Place,po box 2345,usa

If your address is one row in the database then linefeeds must also be being stored. You need to replace these with something else -i.e. a ", " e.g.
=Replace(Fields!Address.Value,VBCRLF,", ")
You would need to get rid of the final ", " in the line so it then becomes:
LEFT(Replace(Fields!Address.Value,VBCRLF,", "),LEN(Replace(Fields!Address.Value,VBCRLF,", ")-2)
Of course you will need to substitute VBCRLF with whatever linefeed character your database is using.

Related

Microsoft SSRS: How to make horizontal flowing fill-in text

Apologies if this has been asked before, I did look around but I'm new to SSRS and I might not know the right keywords to find what I'm looking for.
I am trying to make a new report with a couple of sentences like:
The purpose of this report is to determine an academic plan for student __________, by listing all the courses they will take.
I would like this to display in my report "just like" a paragraph of text, except that I would like the blank filled in with the student's name.
I understand how to do "basic" textboxes and how to bind values to them.
But how to I get a textbox that knows to expand horizontally until it reaches the end of the line, and then continues on the next line? If this was HTML (with some binding libraries like Knockout), I'd stick it all in a <p>, like:
<p>The purpose... <span data-bind="studentName" />, by listing ... </p>
You need to use placeholders, they will do exactly what you want.
Create a text box with the full sentence, then at the position where you want the student name to appear, right-click on the actual text and choose 'create placeholder'.
Once the placeholder is visible, right-click and choose properties, then just set the value to whatever you want.
The placeholder is like an inline textbox, you can set it to be the contents of a field or an expression, give it it's own formatting etc...
If you need a field in a text box with static text, you'd put the text in quotes and use the & to combine them
="The purpose of this report is to determine an academic plan for student " & Fields!NAME.Value & " by listing all the courses they will take."
Text boxes don't expand horizontally though. The text will take up as much room in the text box as it can and then will make a new line in the text box - expanding vertically.
Hoping you are using BI Studio to do this.
I am assuming that your underlying query just produces one value called FieldName and your data source is called DataSource. The text will wrap to your textbox but you can add in a vbCrLf if you want to force linebreak. Concatenating strings you can use + or &.
In your textbox make a formula and set it to:
="First part of string "+First(Fields!FieldName.value, "DataSource")+" rest of sentence"+vbCrLf+"more string"

How to assign the next incremented alpha-numeric string value in a text box using VBA Access?

Currently, I have a datasheet that contains the following data as an example:
FieldOne FieldTwo
TestOne.01 TestOne.01.01
TestOne.01 TestOne.01.02
TestTwo.02 TestTwo.02.01
TestThree.03 TestThree.03.03
TestFour.02 TestFour.02.02
TestFour.02 TestFour.02.03
I have a form that contains a Combo Box. The values of the combo box is all the values in FieldOne. I also have a Text Box on the same form where I would like, upon selecting a value from the Combo Box, assign the next incremented value in FieldTwo of that specific record into the Text Box.
For example, if I select from the Combo Box, the value TestThree.03, I would like to populate the Text Box with TestThree.03.04. If I select the value TestTwo.02, the Text Box should be populated with TestTwo.02.02
What I've tried to get started with so far:
Dim frmDS As SubForm
Dim criteria As String
Set frmDS = getSubForm("form", "datasheet")
criteria = "FieldOne = '" & Me.comboBox & "'"
With frmDS.Form
.RecordsetClone.FindFirst criteria
If Not .RecordsetClone.NoMatch Then
MsgBox .RecordsetClone.Fields("FieldTwo")
End If
End With
However I face 2 difficult problems:
If I select TestOne.01, since there are 2 records containing TestOne.01, it will display TestOne.01.01 instead of the last value TestOne.01.02
I am not sure how to extract the number after the right-most decimal point in the value of FieldTwo, increment it, and append it back to the value in FieldOne so that it can be assigned to the Text Box
I'm not sure if my initial approach is heading in the right direction anyways.
How can I overcome these issues?
Thanks
For question 1, the answer is simple
Instead of .RecordsetClone.FindFirst criteria
use .RecordsetClone.FindLast criteria
For question 2, you just need a bit of VBA code to first get the last code and then format it back to append.
You don't give all the details of your formatting so I'll assume the simplest solution - that is that the last code is 2 digits long. If not you can use a variation of Instr and Mid or Right functions to find the last code
Example:
Dim intLastCode as Integer
Dim strLastCode as String
With frmDS.Form
' Get last two digits from Field 2
strLastCode = Right(.RecordsetClone.Fields("FieldTwo"),2)
intLastCode = CInt(strLastCode) + 1
' Format and append incremented value to Field 1
MyTextBox.Value = .RecordsetClone.Fields("FieldOne") & "." & Format(intLastCode,"00")
End With

Way to add a calculated number of X's to a form input?

I have certain product codes with varying number of letters/digits e.g. 53HD6J, HH88WBD3 (varies between 5 to 10 letters/digits). In order for our barcode to scan these correctly there has to be 13 letters/digits. I don't want to make the user to input -XXXX after each code but rather have Access calculate the difference between 13 and the length of the code and fill the remaining with a X's. Is this possible either by vba or and expression?
I currently am using about 6 IIFs in one formula to fill remaining blanks with X's but hoping there is an easier way.
I have a form to enter in the batch number (product code). Once that form is submitted it links to a report that is printed. On the report are those batch numbers (53HD6J, HH88WBD3). The spot I want to have this feature is in a text box right next to the codes where Access determines the length of the codes and computes the remaining X's to add. This is in barcode font so this text box is where the 53HD6JXXXXXXX would go. Hope that clears it up!
So I have that part figured out. My problem now is my barcode font reads the text no matter what and translates it still so barcode shows up when the batch number is blank (I have four spots for batch codes to be inputted). So what I had before was =IIf([Text31]="",""&[Text31]&"","") which seemed to work. Hopefully I can continue this with the new formula. If that's unclear let me know.
**(The "" & & "" is so the barcode can be scanned).
My formula was wrong right above with the IIf. I figured it out! Forgot I had used ' Like "*" '. Thanks!
You can do what you want with String() and Left().
Here is an example from the Access Immediate window:
product_code = "53HD6J"
? product_code & String(13, "X")
53HD6JXXXXXXXXXXXXX
? Left(product_code & String(13, "X"), 13)
53HD6JXXXXXXX
Based on the update to your question, I think you can use that approach for the Control Source of a text box where you want to display the "expanded" product code.
Pretend your report has a text box named txtProduct_code where the raw product code, such as 53HD6J, is displayed. And there is a second text box where you want to display that value with the required number of X characters (53HD6JXXXXXXX).
Use this as the Control Source property of that second text box:
= Left([txtProduct_code] & String(13, "X"), 13)
Alternatively, you could make it a field expression in the report's Record Source query.
SELECT
product_code,
Left(product_code & String(13, "X"), 13) AS expanded_product_code
FROM YourTable;

Split Text into different lengths in Access 2010

I am currently working on a database in access 2010 that will scan a barcode in PDF147 format.
Basically what the idea is to take the barcode information and split it into the different text boxes of the form.
Ex:
SRGTR17385JOHN DOE DASD17366M
From there I would want to take characters 10-20 and apply it to the first name text-box, then take characters 21-30 and apply it to the last name text box, lastly take the 40th character and apply it to the middle initial text box.
Hope this was specific enough.
If you are obtaining the barcode info from a table, the following query will split out the pieces:
SELECT Table1.BARCODE, Left([BARCODE],10) AS BCOnly, Mid([barcode],11,10) AS FirstName, Mid([barcode],21,10) AS LastName
FROM Table1;
If you want VBA code:
Me.txtBarcode = Left([RS!BARCODE],10)
Me.txtFirstName = Mid([RS!barcode],11,10)
Me.txtLastName = Mid([RS!barcode],21,10)

How do I set a textbox to multi-line in SSRS?

I have a report with many fields that I'm trying to get down to 1 page horizontally (I don't care whether it's 2 or 200 pages vertically... just don't want to have to deal with 2 pages wide by x pages long train-wreck). That said, it deals with contact information.
My idea was to do:
Name: Address: City: State: ...
Jon Doe Addr1 ThisTown XX ...
Addr2
Addr3
-----------------------------------------------
Jane Doe Addr1 ThisTown XX ...
Addr2
Addr3
-----------------------------------------------
Is there some way to set a textbox to be multi-line (or the SQL result)? Have I missed something bloody obvious?
The CanGrow Property is on by default, and I've double checked that this is true. My problem is that I don't know how to force a line-break. I get the 3 address fields that just fills a line, then wraps to another. I've tried /n, \n (since I can never remember which is the correct slash to put), <br>, <br /> (since the report will be viewed in a ReportViewer control in an ASP.NET website). I can't think of any other ways to wrap the text.
Is there some way to get the results from the database as 3 lines of text/characters?
­­­­­­­­­­­­­­­­­­­­­­­­­­­
Alter the report's text box to:
= Fields!Addr1.Value + VbCrLf +
Fields!Addr2.Value + VbCrLf +
Fields!Addr3.Value
I had an additional problem after putting in the chr(10) into the database.
In the field (within the report) add in:
=REPLACE(Fields!Addr1.Value, CHR(10), vbCrLf)
My data was captured in a SL application, needed this for the field expression
=REPLACE(Fields!Text.Value, CHR(13), vbCrLf)
Hitting Shift+Enter while typing in the textbox creates a line break.
I believe you need to set the CanGrow property to true on the Textbox. See http://msdn.microsoft.com/en-us/library/ms159116(SQL.90).aspx for some details.
link break do this
chr(10)
Try this one :
= Fields!Field1.Value + System.Environment.NewLine + Fields!Field2.Value
In RDLC reports, you can convert a textbox to placehoder.
Then right click that textbox placeholder, select placehoder properties and select HTML. Then for multiline to take effect, you have to insert <br/> tag between those lines.