access 2007: entering multiple entries in a single bound text box - textbox

I have a single form, linked to a single table. The form has three bound text boxes, each allow for data entry to the table. In the text boxes you enter a date, a dollar amount, and a client to bill for the postage. My problem is what if I have multiple clients, billed to a single expense.
I want to alter the client entry text box so that i can type in multiple clients, seperated by a comma, and access will know to take the amount entered and divide it between the number of clients entered.
Is this possible? Any help would be appreciated! I taught myself access for the most part and am not very savvy.

Let me start by saying this is not a good idea, however, if it is for your personal use, you can use VBA to split the text string and get a count, you are likely to run into a number of problems, depending on how the bound field is set up.
What I would suggest is a listbox, your two text boxes, and a subform. Using a muti-select listbox you can choose one or several clients. A little code will allow you to iterate through the list and insert a record into a table for each client, with the date and the amount divided by list count. The subform will show the inserted records for checking.
For example:
For Each itm In Me.ListBox.ItemsSelected
sSQL = "INSERT INTO MyTable (ClientID, Amount, InvDate ) " _
& "VALUES ( " & Me.ListBox.Column(0, itm) & "," _
& Me.txtAmount / Me.ListBox.ItemsSelected.Count & ",#" _
& Me.txtDate & "#)"
CurrentDB.Execute sSQL, dbFailOnError
Next
Me.SubformControlName.Form.Requery

Related

How can I use Array Formula with multiple SUMIFs?

I am a beginner with google sheets formulas, I created a formula which is not very efficient nevertheless it works and gives correct output, here is the formula:
=if($C$2:$C = "Check-Out",
SUM((SUMIFS($D$2:$D,$C$2:$C,"Check-In",$B$2:$B,B2,$A$2:$A,"<"&A2)+
SUMIFS($D$2:D,$C$2:$C,"Request Extra Key",$B$2:$B,B2,$A$2:$A,"<"&A2))-
(SUM(SUMIFS($D$2:$D,$C$2:$C,"Check-Out",$B$2:$B,B2,$A$2:$A,"<"&A2)+
SUMIFS($D$2:$D,$C$2:$C,"Return Extra Key",$B$2:$B,B2,$A$2:$A,"<"&A2)))),D2)
I want to copy this formula automatically to the last nonempty row, and I used ArrayFormula to copy this to last row:
=ARRAYFORMULA(if($C$2:$C = "Check-Out" ,SUM((SUMIFS($D$2:$D,$C$2:$C,
"Check-In",$B$2:$B,B2:B,$A$2:$A,"<"&A2:A)+SUMIFS($D$2:$D,$C$2:$C,
"Request Extra Key",$B$2:$B,B2:B,$A$2:$A,"<"&A2:A))-
(SUM(SUMIFS($D$2:$D,$C$2:$C,"Check-Out",$B$2:$B,B2:B,$A$2:$A,"
<"&A2:A)+SUMIFS($D$2:$D,$C$2:$C,"Return Extra Key",$B$2:$B,B2:B,$A$2:$A,"
<"&A2:A)))),$D$2:$D))
it does copy the formula to the last row but the output values are not correct, here is the sheet, Column E contains correct values by dragging down the formula. I want to get same values by using ArrayFormula. Any help would be much appreciated. Thank you
From what I'm understanding you're trying to keep track of how many keys are dispensed and whether it is permitted to dispense an additional key or not (based on rules).
For this I would take a different approach.
I would use a separate Tab (KeyCount) for calculations and only return the OK or NOT OK message back to the KeyLog Tab.
In the KeyCount Tab I would list all the Keys and the number of times they were added to the system, subtracted by check ins etc.
KeyCount Tab
| Key ID | Add Key | Check-In | Check-Out | Return Extra | Count |
For the Key ID Column I would list all the unique keys:
=unique(KeyLog!B2:B)
For Add Key I would sum all the entries that list that unique key:
=arrayformula(sumif(KeyLog!B2B:B,KeyCount!A2:A,KeyLog!D2:D))
For Check-In I would do the same as above but make it a negative by surrounding the formula with -( ). This way this will be a negative number regardless of the sum.
Do the same as above for the other Triggers.
Finally I would add a Count column which simply uses an Array to add and subtract the different triggers in each row to tell you the current balance of keys for each unique key.
This is the figure you use in your KeyLog to decide if it's OK or NOT OK.
BONUS: You can set up a table in another tab which decides if its ok or not ok. For example if number of keys should not exceed 2, then have your array formula in KeyLog look up this table table and return the OK or NOT OK Message. This way if you change policies and allow extra keys you can easily change the rules in this table without messing with the formulas in other tabs. You can also add a longer explanation message such as "Not enough keys" or "Number of allowed keys exceeded" to this table which can show in the KeyLog table.
I hope this helps you solve your problem. Let me know if you need further explaining.
Happy coding!

arrayformula + filter + join function problem

I have 2 sheets 1st sheet contain email address and apps column A -> email and column B -> apps and the emails in column A are not unique they are repeated with different apps.
In 2nd sheet i am extracting the emails with unique formula and I want to have all the comments related to the email in single cell "," separated.
= =iferror(regexmatch(join(",",filter(Sheet1!$B$2:$B,Sheet1!$A$2:$A=$A2)),$C$1),"")This is how the table will look
But I have to manually drag the formula to the entire column and cannot use Ctrl+Shift+enter because the emails will be automatically be added. Thus want to use array formula. But I am not able to get the right array formula. Can anybody help.

Automatically fill out textbox doble clicking on an item in a listbox

Another beginners question, but this time about MS Access Controls.
I have a form where I have a list box full with many items.
What I need to do is when I double click on one of this item stored in the list box should all the textbox filled with an item stored on a different field from the same row where from my table.
I checked many tutorials already but didn't found a good solution.
Thanks for any help!
EDIT:
I have a table with several fields. The list box have the items from the first field(ID). The rest of the fields(Tile, Delivery Date, etc...) represented by text boxes in my form.
When I double Click on one item from the list box will populate the text boxes.
If I select the 5th item from my list box which represents the 5th row from my table every text box should have their item from the same row from the fields represented in the table.
I only want to edit the data stored in the table with this form.
Ok I finally get a solution for this one.
I using the DLOOKUP to get the data pulled to my form after the double-click event.
Dim ctrloop
For Each ctrloop In Me.lbReportID.ItemsSelected
strReportID = Me.lbReportID.ItemData(ctrloop)
Next ctrloop
Me.txtTitle = DLookup("[Title]", "tblreports", "[ID No] = '" & strReportID & "'")
The loop stores all report ID I have in my table. The DLOOKUP using this as a filter. It's like the WHERE in SQL.
When the program run will fill out my Title textbox looking through the title field in my tblreports table filtered with the strReportID.
It's working similarly like this SQL query which I using in a different textbox:
SELECT tblReports.[ID No]
FROM tblReports
WHERE (((tblReports.WorkPacage) = 'CDS'))
AND (((tblReports.State) <> 'Complete'));

Autofill a column in Google Sheets as new rows are submitted through Google Forms

I have a google form that has fields taking up 7 columns in the response sheet. I have reserved the 8th column to compute few fields (basically a formula) and generate a unique ID for that response. I know that when new responses are added, I can drag the box of the 8th column field all the way down to the given number of rows to auto-fill the column. But this type of auto-fill requires a manual effort. What I want is an automated system to keep filling in the column with my formula.
I have tried pulling the column down beyond the current number of rows in a hope for it to auto calculate when the new row is added but a new response simply overwrites the entire row instead of filling in just the seven columns which deletes the 8th column in that row.
The spreadsheet is
https://docs.google.com/spreadsheets/d/1HM2dDRtkF_KlQ8SKoeW2YmjP2dttYAk1_4iCYBVEN8o/edit?usp=sharing
The responses fill up to column H (Member #3) and my desired column is column I (Registration ID) which is aided by column J, K and L.
You can try using
=ARRAYFORMULA(IF(ROW(M:M)=1,"Registration_ID",IF(C:C="UM-DAE CBS, Mumbai", "cbs"&"_"&J:J, IF(C:C="ICT, Mumbai", "ict"&"_"&K:K, IF(C:C="IISER, Pune", "iiser"&"_"&L:L,"waiting for a response...")))))
Just some explanation:
//This one is just to label the first row as Registration_ID so you can replace M:M with any column you want.
IF(ROW(M:M)=1,"Registration_ID"
My first time answering in Stack Exchange so I'm not familiar with the formatting.
Also a heads up, if you wanted to use ArrayFormula() with an If(AND()) or If(Or()) function, just know that the ArrayFormula() requires you to use arithmetic functions like "*" or "+" instead.
So IF(AND(A,B)) will be IF(A*B).
Use the "CopyDown" add-on for Google!
On your Google Sheet that your Form posts to, click Add-Ons > Get Add-Ons > type "copyDown".
This add-on quickly & easily allows the sheet to automatically copy the formula from one of your top rows (adjustable) to the rest of the form's submissions.
Love it!

How to assign a unique ID to a google form input?

Google Forms - I have set up a google form and I want to assign a unique id each of the completed incoming form inputs. My intention is to use the unique ID as an input for another google form I have created which I will use to link the two completed forms. Is there another easier way to do this?
I'm not a programmer but I have programming resources available to me if needed.
I was also banging my head at this and finally found a solution.
I compose a 6-digit number that gets generated automatically for every row and is composed of:
3 digits of the row number - that gives the uniqueness (you can use more if you expect more than 998 responses), concatenated with
3 digits of the timestamp converted to a number - that prevents guessing the number
Follow these instructions:
Create an additional column in the spreadsheet linked to your form, let's call it: "unique ID"
Row number 1 should be populated with column titles automatically
In row number 2, under column "Unique ID", add the following formula:
=arrayformula( if( len(A2:A), "" & text(row(A2:A) - row(A2) + 2, "000") & RIGHT(VALUE(A2:A), 3), iferror(1/0) ) )
Note: An array formula applies automatically to the entire column.
Make sure you never delete that row, even if you clear up all the results from the form
Once a new submission is populated, its "Unique ID" will appear automatically
Formula explanation:
Column A should normally hold the timestamp. If the timestamp is not empty, then this gives the row number: row(A2:A) - row(A2) + 2
Using text I trim it to a 3-digit number.
Then I concatenate it with the timestamp converted to a number using VALUE and trim it to the three right-most digits using RIGHT
Voila! A number that is both unique and hard-to-guess (as the submitter has no access to the timestamp).
If you would like more confidence, obviously you could use more digits for each of the parts.
You can apply unique ID numbers using an arrayformula next to the form data. In row 1 of the first rightmost empty column you can use something like
=arrayformula(if(row(A1:A)=1,"UNIQUE ID",if(len(A1:A)>0,98+row(A1:A),iferror(1/0))).
A few comments regarding the explanation provided by #Ying, which I will try to expand, as it is very good.
> Column A should normally hold the timestamp.
In my case, it is date+time stamp.
> 4. Make sure you never delete that row,
even if you clear up all the results from the form
That issue can easily be avoided by placing the formula in the header like this
={"calculated_id";arrayformula( if( len(C2:C); "" & text(row(C2:C) - row(C2) + 2; "000") & RIGHT(VALUE(C2:C); 3); iferror(1/0) ) )}
This formula provides an string for one cell, and a formula for the next one, which happens to be an array formula which will cover all the cells below.
Note: Depending on your language settings you may need to use ";" or "," as separator among parameters.
> 5. Once a new submission is populated,
its "Unique ID" will appear automatically
Issue
And here is the issue I see with this solution.
If the Google Form allows responders to Edit their responses, the date+time stamp will change and so the calculated_id.
A workaround is to have 2 columns, one is the calculated_id and the other will be static_id.
static_id will take whatever is on calculated_id only if itself has no data, otherwise it will stay as it is.
Doing that we will have an ID that will not change no matter how many updates the response experience.
The sort formula for static_id is
=IF(AND(IFERROR(K2)<>0;K2<>"");K2;L2)
The large one is
={"static_id";ArrayFormula(IF(AND(IFERROR(M2:M)<>0;M2:M<>"");M2:M;L2:L))
}
M or K -> static_id
L -> calculated_id
Remember to put this last one on the header of the column. I tend to change the color to purple when it has a formula behind, so I don't mess with it by mistake.
Extra info.
The numeric value from the date/time stamp differs when it comes from both or just one. Here are some examples.
Note that the number of digits on the fractional part differ quite a lot depending on the case.

Resources