I was trying to design a form in access, when i was in the marital status field i think it was a good idea to use a group of option buttons but i can save letters only numbers. This is not bad but i would like to save letters because is easier to remember. I have 4 values. I have other similar fields, like sex, education and so.
You can use Choose. It returns values from input of 1 to n and Null for values outside the range. This can be used by Nz to return a value for unknown inputs.
This can be used a ControlSource for a textbox, here for values between 1 and 4:
=Nz(Choose([NameOfYourOptionBox], "Male", "Female", "Hermaphrodite", "None"), "Unknown")
Related
I'm trying to write a formula in Excel where if value in B is “Eligible/Previously Eligible” and value in C is more than 365 days before today and value in D contains either 10 or 20, then return the value in A. I’ve been searching around and have written this:
=IFERROR(INDEX($A:$A,SMALL(IF((COUNTIFS($B:$B,"Eligible/Previously Eligible",$C:$C,"<"&TODAY()-365,$D:$D,{"*10*","*40*"})),ROW($A:$D)-MIN(ROW($A:$D))+1),ROW(A1)),COLUMN(A1)),"")
And have activated with the CTRL+Shift+Enter combo, but it just pulls in everything from A regardless of what is in B, C, or D:
#Solar Mike and #Scott Craner, thanks! This has gotten me closer but not quite there. I have a formula now that works to return the ID numbers that meet the criteria:
=IF(AND(B2="Eligible/Previously Eligible",D2<TODAY()-365,D2<>"",OR(SUM(COUNTIF(C2,{"*10*","*20*"})))),A2,"")
But I still can't get it to give me a list without white space. So, I can get what's in the "ID Numbers with Problems" column, but what do I need to write to get it to show the way I've done it manually in the "What I want" column?
image of what
Add a helper column:
=and(find("*elig",B2,1)>=1,now()-c2>=365,D2/10<=2)
Drag down to test each row. Then a results table based on those that give true.
Or use sumproduct() with column A to give the IDs.
I have a bank register on the left. I want a code on the right to tell me sum all the times the description "Rent" is paid in that month. I've tried index, sumproduct and sumif. I can't find the correct way to have it search by month, year and text.
It isn't clear what format your tables are in.
SUMIFS is the easiest solution but it will only work if the bank register uses the Excel date format. It gets a little complicated if those dates are formatted as text.
Building a SUMIFS formula begins with the SUM RANGE. This is a welcome change away from the backwards construction and wrongly named SUMIF (looks more like an IFSUM if you ask me)
=SUMIFS(SUM RANGE, CRITERIA 1 RANGE, CRITERIA 1, CRITERIA 2 RANGE, CRITERIA 2, CRITERIA 3 RANGE, CRITERIA 3...)
Using your example:
SUM RANGE, the 'Debit' column of the bank register (BankRegisterDebitRange)
CRITERIA 1 RANGE, the 'Description' column of the bank register (BankRegisterDescriptionRange)
Criteria 1, the string "Rent"
Criteria 2 Range, the 'Date' column of the bank register (BankRegisterDateRange)
Criteria 2, this formula string ">="&EOMONTH(RentTableDate,-1)+1
Criteria 3 Range, the 'Date' column of the bank register (BankRegisterDateRange)
Critera 3, this formula string "<="&EOMONTH(RentTableDate,0)
Putting it together:
=SUMIFS(BankRegisterDebitRange, BankRegisterDescriptionRange, "Rent", BankRegisterDateRange, "=>"&EOMONTH(RentTableDate, -1)+1, BankRegisterDateRange, "<="&EOMONTH(RentTableDate, 0))
If your data is fornatted as text then you need to decide if you want to use helper column or not or if you want a single formula. A helper column may be desirable if you want to use SUMIFS or perform additional analysis with simple formulas. A different array based formula may be desirable if you don't want a helper column, for example SUMPRODUCT or SUM.
There's already great answer showing how to use SUMPRODUCT so here is an example of how to build an array formula with SUM when your data is fornatted as text.
=SUM((BankRegisterDebitRange)*(BankRegisterDescriptionRange="Rent")*(DATEVALUE(BankRegisterDateRange)=>(EOMONTH(RentTableDate,-1)+1))*(DATEVALUE(BankRegisterDateRange)<=MONTH(RentTableDate,0)))
This is a true array formula and must be entered with Ctrl + Shift + Enter
I was surprised by some of my results during testing. Mainly how Excel was still treating text as dates in some cases but not others. For example, DATEVALUE was needed on the bank register side but that wasn't the situation with the rent table because EOMONTH worked just fine without it. I believe it is related to another odd behavior: when I create a text formatted cell in A1 and then enter a date, regardless if it is preceded by an apostrophe or not, then if I enter =A1+1 in any other cell, that cell becomes formatted as text and displays Excel's numerical value of the day after the date in A1. What I expected was a #Value! error. I suspect this is what keeps EOMONTH from bonking and the mysterious nature of arrays somehow preventing that behavior from carrying over to SUMIFS... but I really do not know why this is happening.
Suppose you have the following named ranges:
BankDate being the date column in your bank register table;
Desc being the description column in your bank register table;
Dr being the debit column in your bank register table.
If the look up date are text, you can use the following formula:
=SUMPRODUCT((Desc="Rent")*(TEXT(BankDate,"mmm yyyy")=G2)*Dr)
If the look up date are date, you can use the following formula:
=SUMPRODUCT((Desc="Rent")*(TEXT(BankDate,"mmm yyyy")=TEXT(G4,"mmm yyyy"))*Dr)
Change G2 or G4 in the above formulas to suit your actual case.
The logic is to use TEXT function to convert the BankDate into the same format as your look up date, and then use SUMPRODUCT function to return the rent by month.
Ps. using SUMPRODUCT may be an overkill, as SUMIFS suggested by #ProfoundlyOblivious is actually faster in excel calculation.
Ps2. as pointed out by #ProfoundlyOblivious, there is an interesting behavior in Excel in terms of treating text date as 'real' date in certain scenarios. Although it may not be relevant to the question of this post, I'd like to share some of my test results here for anyone interested:
I am trying to loop through Column Values inside my Table.
I have a register form, which provides the user with UNIQUE ID, based uppon his information.
For example:
Country = Austria
Each user that selects country Austria will get some sort of Unique Value for that match (lets say 00).
Account ID look like this:
XXXX00UNIQUECODE
Each country has it´s own unique value: (AT = 00, DE = 01, etc)
Now, I want to generate a UNIQUE CODE for each user, that will be just an increment (+1) value of the previous UC value stored in the table, for the same country!
In order to do that, I need to somehow loop through the Column, where the Account IDs are stored and search for the match.
The thing is, when a user tries to generate the UNIQUE CODE, he does not have it yet, so he has only:
XXXX00
Now I need to find all the XXXX00 strings in my AccountID Column, and store them in an Array - then find the Max Value of those and increment it.
BUT I dont know how to search for a part of the string inside a Column of the Table ?
Just the XXXX00 part, not the entire Account ID XXXX00UNIQUECODE.
Agh, I hope you can understand me. It´s quite complicated I know, but I´m really stuck here. Hopefully, someone will know what I mean and maybe even find a smoother solutions for this.
Thanks in advance!
You're pounding a square peg into a round hole. Why not just create a new column called UserID and then you can do:
SELECT Max(UserID) FROM MyTable WHERE Mid(AccountID, 5, 2) = "00"
and increment it by 1.
Better yet, store CountryCode, UserID and the XXXX part in separate fields, and index them. It'll save time when you search or filter, which I'm assume you're going to be doing.
I'm creating a budget template in Livecycle Designer.
I have a field where users can enter a percentage as a number (for example if you want to enter 75%, just enter 75).
I'd like another numfield box to take this number and convert it to .75
Can I do this across num fields or do I have to do it one box (where a user enters 75 and it turns into .75 automatically).
If you just want to enter integer numbers in the numeric field then that can easily be done by just taking a numeric field and then simply entering this javascript in the "exit event" of the field as:
var value1=this.rawValue;
this.rawValue="."+value1;
I have several textboxes and users are entering same data in one of these fields. I have another table which is store machine_no. I would like to restrict user for possible wrong entries. Example if there is no machine_no #4 on table, user will be warn with message box.
Machine_no Value1 In first day
1 500
2 400
3 600
Machine_no Value1 second day
1 8678
2 45645
3 54645
Thanks in advance
If you really want to restrict the available choices, I'd replace the free form textbox with a dropdown list of choices populated from your table.
You could use a NumericUpDown control to let the user enter only integers and validate against a generic List of integers or an array of integers (you can load the list with the existing machine numbers on your data base table), and finally you can use ErrorProvider control to show a warning to the user if enters a not valid number.