Putting code in a text box (MS Access) - ms-access

I am using a textbox for the header of my report, and based on what the user selects it will be "Baseline 8", "Baseline 9", etc. What I would like to do is have the text box coded so whatever number the user selects is entered into the text box. I managed to do it by using two text boxes, one just says "baseline" and the other text box says "=[Forms]![Navigation Form]![NavigationSubform]![Combo21]" and it will enter the correct value. But what I want to do is put it all in one box, and when I put "Baseline =[Forms]![Navigation Form]![NavigationSubform]![Combo21]" in the text box it doesn't work, it just leaves the code as the header when I generate the report. Is there something I'm not doing correctly?

First of all, when you state that a "textbox says", you really mean that "the Control Source property of the textbox equals." For a textbox (and some other controls), the value that you see on the actual form IS the Control Source property. I am not being picky for its own sake, rather it is important to recognize what value you are editing.
The Control Source property can essentially contain two types of values. The first is without an equals sign and it indicates the name of a field from the form Record Source. In that case, it binds the control to the field directly so that it automatically loads from the field and saves changes back to the field.
The second type of value always starts with =. It is a VBA code expression and can include calls to functions and other VBA operators. In your case, you want to concatenate (i.e. combine) two strings: one literal "Baseline" and one pulled from an access object [Forms]![Navigation Form]![NavigationSubform]![Combo21], so you need to use the string concatenation operator &.
="Baseline " & [Forms]![Navigation Form]![NavigationSubform]![Combo21]

Related

How to display parts of value from database with different font size in SSRS report?

One of my columns has a value that looks like this -> "$5.95 (Park costs)"
and I need to display the value in column in SSRS report like this:
$5.95
(Park costs)
but font size of "(Park costs)" must be smaller than the price.
Is something like that even possible? To somehow make text that does not contain a number, dot or dollar sign smaller?
You can do this. You'll need to split up each component of the text column and then place each half in a placeholder. You can then format each placeholder individually.
This solution assumes that your column always contains a "(". If not you should be able to modify it to suit.
I Generated some test data and and placed it in a normal table (tablix) control.
I then added some new columns for testing that each part was working as expected.
The expression for "Cost" column is
=TRIM(LEFT(Fields!MyColumn.Value,InStr(Fields!MyColumn.Value, "(") -1))
The expression for the "Caption" column is
=TRIM(RIGHT(Fields!MyColumn.Value, LEN(Fields!MyColumn.Value) - InStr(Fields!MyColumn.Value, "(") + 1))
Once this was working OK I added the "Final Column".
To add a placeholder, click inside the textbox so the cursor appears then right-click and choose "Create Placeholder"
I added two placeholders with a space between then and set the values to the expressions above respectively. I then right clicked the placeholders chose "Placeholder Properties" and formatted each individually.
The final output looks like this. (I left the test columns in for clarity)

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"

Retrieving value including input mask from TextBox field - Access VBA 2016

I have an input mask of JAAA-AAA on a TextBox, so when the user enters that input field, they will see this: "J___-___".
However, when they fill it out like so, J123-321, and I get the value using [myfield].Value, it says that the value is only 123321. It strips the preset 'J' and '-' I had in there. How can I prevent the stripping of these characters when I retrieve the value from this field?
You need to set the second part of the input mask property to 0.
If you look at the documentation, you can see it has 3 parts, and the 2nd part controls if the mask is stored with the data, or only the data is stored.
The final mask property would be the following:
\JAAA\-AAA;0;_

Microsoft Report Designer Line Through Text when value not Empty

Has anyone used LineThrough text on Microsoft Report Designer within the expression value?
Example:
=Switch(Fields!a.Value is Nothing, "text here".LineThrough, Not(Fields!a.Value is Nothing), CStr(Fields!a.Value))
I need the "text here" to be strikethrough if a.Value is nothing.
You need to use an expression to show the value you want and then Harry's answer to set the LineThrough.
You can simplify your SWITCH statement for the value like this..
=SWITCH(
Fields!a.Value Is Nothing, "Text Here",
True, Fields!a.Value)
or if the expression will not get any more complex than you have then use IIF
=IIF(Fields!a.Value Is Nothing, "Text Here", Fields!a.Value)
If you need only part of the textbox then the easiest way is to use placeholders. These act almost the same way as a textbox but you can have several placeholders in a single cell/textbox each with it's own properties.
To add a placeholder click the cell/textbox first to get focus then right-click before or after any existing text/placeholders. Select Insert placeholder and set the expression as you wish, you can also format the placeholders font/color/decoration etc.
As an example I've got a small dataset with country names. If the country contains the word "Island" then I show different text and change the text decoration on one of the place holders. In the design you can see there are 3 placeholders, some text then a field then some more text.
When I run this I get the following output.
I've set strike thru on the countrydesc field placeholder but you can do the same on a text placeholder. You still have to do it in two parts, and expression to set the text value and an expression in the placeholders font properties to set LineThrough
You can set the condition on the Font/ TextDecoration on the selected report Item. There is an option for LineThrough.
For Example
=iif(reportitems!Textbox7.Value = "Cartons","LineThrough","Default")

ms-access calculated controls

can someone give me an example of what a calculated control is in ms-access?
Say you add a text box to a form, normally it binds back to a specific field in a table, and its contents reflect the contents of that field. A calculated control does not refer to a specific field in a table, rather it displays the calculation done on one or multiple fields in the database. Sometimes, it may not use any fields.
Example of control source value from a calculated control
=[YearlySalary]/52
Presuming that there is a field called yearly salary in the table the form is based on.
A control that simply displays this field would have the following in the control source
YearlySalary
Note the control source for a calculated control starts with an =
you mean this?
Setting the Control Source of a control, generally a textbox, to a calculation creates a calculated control:
=1 * 2
=[TheDate] - 1
=[Stock] * [UnitPrice]
=DlookUp("TheField","TheTable","FieldX=1")
Different cases:
Text box control: here you may be using a trim("text") function to remove spaces and clean up the data--that process requires some calculation
List box control: a calculation may be involved in the query that comprises it's row source. The calculation could be the combination of some kind of cyclic function on a numeric field value which then dramatically changes the order of the data if so directed.
Command Button: a variable could change with the number of presses which in turn changes the command mode of the button. Could change the color of the button, or could hide the button after a certain number of clicks, or could change the column of the listbox that is sorted in a query--each click advances the sort to the adjacent column to the right.