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

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;_

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)

Putting code in a text box (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]

HTML input type number seems to be allowing a letter after a number

I'm using standard HTML TextBoxFor helpers in an MVC5 project and wanted to set a textbox to accept numeric values only.
So I've set the type to be number.
#Html.TextBoxFor(model => model.PP_IMP_M1, "{0:0}", new { #type ="number"})
I'm not sure what the functionality of the HTML input type=number is supposed to be but when I type only letters in the textbox and tab out, the textbox clears itself as the value was not numeric. This is expected and correct.
However, if I type the first character as a number and follow this with random letters then the mixed text value remains in the textbox. I know the character 'e' may have been acceptable but I'm entering things like '12hgf' & '45dddd' and the textbox accepts the value after I tab out.
Is this the expected behaviour for an input with type set as number?
I was hoping the type=number would only accept numeric values without me having to use javascript or jquery.
Any help on this issue would be appreciated.
Shuja

Auto insert area code

I have a text box in Microsoft Access 2013 that corresponds to a telephone number. The text box has the input mask of:
!\(999") "000\-0000;;_
I am trying to auto insert the area code. For example, when a users goes to enter a telephone number, the area code is already populated into the text box. I have tried to set the default value in both the table design and on the property sheet of the text box but no luck. Its always aligned to the right. For example it looks like this:
If I add spaces to the default value on the text box property, the input mask is ignored and Microsoft Access generates an error stating:
The value you entered isn't appropriate for the input mask '!(999") "000-0000;;_' specified for this field.
I have contemplated modifying the table structure to include a specific field for an area code, but that is my last resort.
Is there a more efficient way to automatically populate the area code in the text box when a new record is generated?
You can write a function in VBA to do this. Something like;
Function FormatPhone(PhoneNumber As String) As String
FormatPhone = "(719)" & PhoneNumber
End Function
This function will take a string like '123-4567' and return '(719)123-4567'.
In the AfterUpdate event of your phone number field put;
[TextBoxControlName].Value = FormatPhone(Nz([TextBoxControlName].Value,""))
and this will add the formatted string to the text box.

how do I change a lookup value to whole a number in ssrs?

How do I format a number with 2 decimal places to a whole number?
I used the Lookup function to get a result, but formatting decimal to whole number does not work for this value. I did Text box properties -> number -> whole number doesn't work for one of my value. Also customize number to #,### but its not changing anything.
How do I make this value display as a whole number?
You may be confusing how the number is displayed (which can be controlled using text box properties) and it's actual value. It sounds like the value returned from the lookup is not a number, it might be a string/text value instead which would explain why it was not affected by number formatting.
One option is to convert the value to an integer (whole number) in the lookup expression itself, using a function to convert the value: CInt()
For example if your expression currently looks something like this:
=Lookup(Fields!SomeField.Value, Fields!SomeDatasetField1.Value, Fields!SomeDatasetField2.Value, "SomeDataset")
then you can change it to:
=CInt(Lookup(Fields!SomeField.Value, Fields!SomeDatasetField1.Value, Fields!SomeDatasetField2.Value, "SomeDataset"))
Or if you want to keep the original value, but just change how it is displayed then convert to a decimal value instead:
=CDec(Lookup(Fields!SomeField.Value, Fields!SomeDatasetField1.Value, Fields!SomeDatasetField2.Value, "SomeDataset"))
and then use the text box formatting options to control the displayed format.