How can I prevent submission of a Foundry form if one field has a greater value than another? - palantir-foundry

I’ve setup a Foundry Form with two numeric fields (let’s call them Num A and Num B). I’m trying to add a constraint such that the form cannot be submitted if Num A < Num B.
How could I accomplish this?

This can be accomplished by doing the following:
Define a new Calculation field that stores the result of subtracting Num B from Num A. The configuration for this field should look something like the screenshot below:
Add a validator to the Calculation field such that its value cannot be negative (in other words, it must have a minimum value of 0). Configuration for this validator should look like the following:
If these steps are followed, the form will block submission if Num A < Num B as shown in the screenshot below.

Related

Saving calculated control on a form in a table - Access [duplicate]

I have a textbox in a form that I created.
I want to add an expression in the textbox's Control Source property.
I also want to bind the textbox to a field in the table using Control Source propety of the textbox.
Is there any way I can add a field name and an expression in the control source property of a particular textbox?
The expression basically adds up couple of numbers and displays the output in that textbox. And I want the output to be stored in a field in the table.
You could link the text box to the table control source and then set the value of the text box to the result of the expression in the AfterUpdate property on the two objects the contain the values you want to add.
For example
me.textbox.value= int1 + int2
This value should then be written to the table.
If you have a text box named txtMy_field which is bound to a field named My_field in your form's record source, you could use the form's on current event to load the sum of those other two numbers into txtMy_field.
If you don't want to over-ride existing values stored in My_field ...
If IsNull(Me.txtMy_field) = True Then
Me.txtMy_field = Number1 + Number2
End If
If you do want to over-ride existing values stored in My_field, eliminate the IsNull() condition.
Me.txtMy_field = Number1 + Number2
If Number1 and Number2 are from other controls on your form, you could also use their after update events to update txtMy_field value on demand.
However, I'm unsure how well I understand your question. These are only general suggestions and I hope they point you to something useful. Incidentally, if those two numbers come from two different forms (as in one of your previous questions) and you intend to display and store their sum via a third form, this could be more challenging than it appears from this question.
If you have textboxes with names text1 and text2 and you will save your answer in text3
you should give this code in text3 properties Control Source:
=Val([text1])+Val([text2])

#Error in Textbox on MS Access Form, when using DMax?

So I have literally used the same code format on 4 other Forms:
Here's the working code from those three forms :
=DMax("ID","tbl_Users")+1
=IIf([lst_DeviceType].[Column](0)="Cell Phone",DMax("DeviceNum","tbl_Cell_Tab","DeviceNum < 70000")
+1,DMax("DeviceNum","tbl_Cell_Tab")+1)
=IIf([frm_type]=0,DMax("DeviceNum","tbl_PC_Lap","DeviceNum < 100000")+1,IIf([frm_type]=1,
DMax("DeviceNum","tbl_PC_Lap","DeviceNum < 50000")+1,DMax("DeviceNum","tbl_PC_Lap","DeviceNum < 40000")+1))
=DMax("DeviceNum","tbl_Printers")+1
The goal here is to pull the current largest number in the Key from the table and from it get the next one in line so as to be calculated and stored for use later in a module that will audit changes to the tables. So I am using the format DMax("DeviceNum", TABLENAME) + 1
My latest form won't accept this format, instead throwing #Error
=DMax("DeviceNum","tbl_ThinClients")
And for the life of me I can not figure out why I keep getting this. I have deleted the textbox, and recreated it.
Here's a snip of the table in design mode
Here's a snip of one of the tables it works with
Any ideas as to why? I mean the only difference I see is that the Printers is a "Large Number" Data type (Values > 80000)
So apparently, though I don't know why, you can't DMax Large Number fields. The solution was to set it to a "Number" and use that.

During Select Statement refer to a fields declared name

I'm currently building a report which at some point compares a few fields and works out the difference between the two.
It first checks which is larger field A or field B and whichever is biggest it then compares to C and tells me the difference. (Other calculations to follow but the answer to this will carry on through the scope of the project)
The problem I've got is A and B are calculated fields and I don't want to keep pasting this code in over and over again for each calculation.
Myself and others will probably refer back to this code regularly and it is already getting very clogged up.
The two existing lines are:
IF(MAX(LEAST(MANFU.height,width)) < 44,0.220,
IF(MAX(LEAST(height,width)) < 68,0.340,
IF(MAX(LEAST(height,width)) < 80,0.400,
IF(MAX(LEAST(height,width)) < 90,0.450,
IF(MAX(LEAST(height,width)) < 122,0.610,
IF(product_code LIKE '%_BB',2.508,'')))))) AS Volumetric_Weight',
and
SUM(boxweight)+SUM(Itemweight)+SUM(packagingweight) AS 'Expected_Weight',
I want to add a field that be able to carry out the following calculation:
IF(GREATEST(Volumetric_Weight,Expected_Weight) > Courier_Weight,'Overweight Item','Underweight Item')
Is there a way to refer to another fields alias?

MS Access Table Design for Employees with different training requirements

Please help with me a conceptual problem I've been trying to figure out for the past 3 days now. I'm trying to use Access to centralize the tracking of training that was previously done on separate excel spreadsheets. I have about ~340 employees that are categorized into 12 different positions all with varying degrees of required training. I have an example below:
Position 1: Class A, Class B, Class C
Position 2: Class A, Class B
Position 3: Class A
Position 4: Class A
As you can see, all 340 personnel require the Class A training. But only some positions require the Class B or even Class C. Right now I have a single table with the individuals name and associated contact information and all 12 possible classes. All I want access to do is store the date they've completed training, nothing else. The problem that I'm running into is that the Date/Time field cannot distinguish between someone that is required to take that class and simply hasn't done it yet (a null value) vs. someone that is not required to take the class and obviously hasn't completed it (also a null value).
What I've tried:
-A query using calculated fields that will enter in the value "NOT REQ" if the job position does not require the training. An example is below:
HAZMAT Inspector: IIf([POSITION]="Load Planner",[HAZ Inspector],"NOT REQ")
Why it doesn't work: Inserting text into the field changes it from a date to a text field so I can no longer use Date functions to determine if training is expired. Also, I cannot edit the field on a form and save it back to the original table due to it being a calculated field.
Possible Solution(?): Use a SQL Update statement in VBA to write the value of a calculated field back into the original table? I still run into the problem that I cannot update the field to begin with on the form...
-Separate Tables for each Position(?): The main problem I see with this is that a lot of positions require the same exact class so I'd be entering in a lot of redundant information.
-Separate Tables for each Class (?): I can see how I'd be safer with this route, but for it to be useful I'd imagine I'd have to write some type of VBA code that says when I assign someone to Position X, his Employee ID is automatically populated in Tables A, B, & C based on his position's training requirements. Is that doable? Is this the best option, or am I just off the mark?
As you already explained, you cannot make entries in a calculated field. You will need a different approach. The approach depends if you display only one employee per form (Single Form) or if you display a list of employees (Continuous Form or Datasheet).
On a Single Form I would simply disable the fields which do not apply
me!txtClassBDate.Enabled = me!txtPosition = 2
You can call this code from Form_Current and possibly in the AfterUpdate of a control used to change the position type.
The other possibility is to use conditional formatting. Select the date-TextBox; then open menu "Format" > "Conditional Formatting..." (I do not know where that is on the ribbons of Acc 2007+). Here you can define the appearance of the control depending on the evaluation of an expression. You can also set the control in a disabled state.

Ms Access : Math Functions with a report

I have a report in access which displays the number of times a certain procedure is a done as well as a break down of the scores received, which can either be "N" "B" or "C"
I want to include in my report the % of procedures that are deemed below standard. These are the scores and of N and B combined.
I have written the following to work this out
=([B]+[N])/[Total Of Entry ID]*100
The problem occurs if either N or B do not have a value which is possible then it does not calculate the percentage. Is there a way I can tell it that if there is no value to assume the value is zero?
Thanks in advance.
You can use the Nz() function to apply a substitute if the field is null;
=(Nz([B], 0) + Nz([N], 0))/ ...