Create entry in Access form based on entry chosen from combox box (without including the entry from the combo box) - forms

I use Access to maintain a list (with details) of cases I work on (I am a legal professional). I want Access to add an unique case identifier to every case. I use a form to enter the data in the database.
I wrote this very simple code to add the Case ID nr:
Private Sub Command81_Click()
If Not IsNull(Me.Case_ID) Then
DoCmd.CancelEvent
Else
Command81.Enabled = True
Me.Case_ID = Me.Combo321 + Format(Me.[Date Original Event], "yymmdd") + Format(Time, "hhmmss")
End If
End Sub
The idea is I fill the different fields in the form and then click a button to add the case ID (listed in the textbox (in the form) and field (in the database) called 'Case_ID').
When I click the button it should check whether there is already a case ID. If there is it will not create a new one. If there is none a new case ID will be created based on the country where the case happened (Combo321) + the date when the original event happened + time I created the case ID.
The country where the case happened is choosen from a dropdown menu (Combo321). The options in the dropdown menu come from a table with a list of countries:
The Netherlands, United Kingdom, Germany, etc.
If possible I want to keep the list of (full) country names in the dropdown menu, but in the case ID use a 2 or 3 character abbreviation. So if I choose from the dropdown menu that the case happened in The Netherlands I would like the case nr to start with NL, if the case happened in the United Kingdom I would like the case Nr to start with UK, etc.
Is it possible in the table with the country names to make a second column with the abbreviations and then in the code somehow to have the case ID start with the entry in that 2nd column that 'belongs' to the relevant entry in the first column (the full country name) that I picked from the dropdown menu?
Or maybe there is another way of doing this?

Yes, create field in table. Then have that field in combobox RowSource (multi-column combobox). Combobox properties:
RowSource: SELECT CountryCode, Country FROM Countries;
ColumnCount: 2
ColumnWidths: 0";1.0"
BoundColumn: 1
ControlSource: field to save selected combobox value
Two-letter CountryCode will be saved into record if combobox is bound to field. It will also be used by your code.
Saving data dependent on other data is usually not necessary and often a bad idea. This identifier can be constructed by expression when needed for display.
Also, advise to develop habit of using nn for minutes instead of mm. It actually doesn't seem to make a difference in Format() function but I have seen usage where it does, although can't recall exact circumstances.

Related

MS Access form: Mother combo box not showing correctly in table, but daughter combo is

I set up two combo boxes, a mother and daughter. Mother (one) controls the daughter (many). Mother consists of 7 columns, I only need 2 to display correctly. the first column is the Identifier column, the second column is the name. Once the item in the mother combo is selected, the daughter is filtered to only show those associated names to the mother.
Everything works fine, but, when I look at the data in the table, the identifying number is in the name column where there should be a name. In the properties I have the following set up:
Tab Format: Column Count 7
Column Width: 1;3;0;0;0;0;0
Tab Data: Bound Column 1
When I change this to 2, it puts the proper information into the table, but it breaks the link to the daughter - I see no information in the daughter combo box in the form.
Row source is basically a query from the table where this data is being retrieved.
Daughter cell has basically the same set up except in the Row source query, the associating ID column has code that goes something like: [Forms]![frm_Master]![cboMain] - in the Criteria of the MainIDs column. This column is the key column in the Mother table.
Forgive me - as I'm a newby at this I'm happy to work offline. I may have done this completely wrong, but, I don't think so, because most of it works except that one piece.
Edit: The row source for the mother is as follows.
SELECT tbl_Main.MainIDs, tbl_Main.MainAccount, tbl_Main.Main_City, tbl_Main.Main_State, tbl_Main.Main_mgr, tbl_Main.MainE, tbl_Main.Main_Date FROM tbl_Main GROUP BY tbl_Main.MainIDs, tbl_Main.MainAccount, tbl_Main.Main_City, tbl_Main.Main_State, tbl_Main.Main_mgr, tbl_Main.MainE, tbl_Main.Main_Date ORDER BY tbl_Main.MainAccount;

Tableau find count of dimension for each of other dimension

I have 3 columns in my data "Date", CustomerID and Action Type (There are 10 different types of Action type like item hover, product click etc)
I want to eliminate those customers who has interactions of less that 20.
For example, for a customer ID say 10, if the count of all the action type against this customer is less than 20 I want to eliminate that customer. I want to do this for each ween and create a line graph may be.
Somebody please help, Although I am trying to do this in tableau but excel and access solutions are welcomed too. I have tried everything I could but still couldn't do it. My calculated field only works if I use customer Id along wth count which gives me a table that I dont want.
Assuming Action Type cannot be null, put CustomerID on the filter shelf, select the "Use All" radio button at the top of the filter panel, switch to the Condition tab, Choose "By Field", and require the SUM of the Number of Records to be >= 20
If Action Type can be null, do the same but use COUNT of Action Type instead of SUM of Number Of Records.
Filters have multiple tabs. You can see a summary of how the filter is defined at the bottom of the General tab.

How to reuse data in multiple records in Access form

Big question: How can I make Access automatically fill in a cell in a form based on previously entered data?
I need to enter leave details for members of staff. I tend to enter these by date, and in one to two week chunks. Is there a way to have the next new record automatically fill in the date part of the record with the previously entered one?
Table structure
Staff: StaffID, Name
Absences: ID, StaffID, Dateaway, OtherDetails
I want it to automatically fill in DateAway with the entry of the row above it, or the previously entered row, as I will enter say 10 dates in a fortnight, but 50 entries over those dates. I enter them chronologically, and after the fact (So just defaulting to TODAY() won't work).
There's a shortcut Ctrl+' that does pretty much what I need, wondering if there's a way to do that with the generation of a new record.
You have to be careful with this. If your form is bound to a table/query, you're going to insert a junk record every time you're done with the form. However, if it's unbound you can do this using DMAX, in the After Insert event of the form.
Private Sub Form_AfterInsert()
txtDateaway.Text = DMax("Dateaway", "Absences", "StaffID = " & Me.txtStaffID)
End Sub
This is, of course, assuming your Dateaway field on your form is called txtDateaway and your StaffID field is called txtStaffID.

Dynamic Number Of Inputs In Form

This is supposed to be something very common in access: Say you have a table Employees with a many-to-many relationship with a table Workdays. As in, A day of work is a record in Workdays, and for any day of work there can be multiple employees who worked that day (Which is shown with a third table, I think it's called a junction table?).
Now, say you want to create a form that the user inputs the employees who worked on a certain day. There is a changing number of employees per day, therefore a changing number of text boxes/combo boxes to input the employees in.
I want to ask if there's a conventional/convenient/acceptable way to do this. I've thought of 2 ways: Having a certain maximum number of text boxes invisible, and every time one receives input set the visible property on a new one to Visible=True, and second way by using the CreateControl method. Both ways seem a little pointlessly complicated for something that should be very common.
You don't have to mess with dynamically creating or showing/hiding individual controls. All you probably need is a main form for the Workday with a Subform Control for the Employees who worked that day, something like this:
Design View:
Form View:
The subform control contains a Continuous Forms form that is bound to the junction table [TimeCards].
Workday EmployeeID HoursWorked
--------- ---------- -----------
9/10/2014 1 7
9/10/2014 3 6
9/10/2014 4 9
The "child" subform linked to the "master" form by the [Workday] value. You can enter a variable number of entries for a given Workday by simply adding new rows to the subform (via the "New Record" row with the asterisk beside it).
For more information, see
Create a form that contains a subform

Filemaker 12 -- display one value, store another

I'm building a database in FileMaker 12 that will, among other things, keep a list of jobs (indicated by numeric ID) and the employees who had billable time for that job.
Given three tables:
Employee ( empName, empID, salary, ... )
JobHours ( empID, jobID, hrsWorked, ... , refID)
JobCost ( jobID, expenses, profit, ... , refID)
Where:
Employee is my personnel roster matching names to numeric employee IDs and stats (salary, et al) ;
JobHours is a list of employee participation -- whenever an employee spends time on a job, this table has a line that shows their ID, the job ID, hours worked, and a few other things;
JobCost is a daily record of jobs. One entry in this table refers to the activity for a single job on a single day. Additionally, each entry gets a system generated unique ID (since neither jobID nor date is unique) to relate to JobHours (resulting in a list of who worked on a particular job on a particular day).
I have a form showing records from JobCost. For each record, I can see in a portal, showing records from JobHours, who worked on that job on that day.
Now, the issue.
In my portal, I want to have a drop-down list of employee names pulled from a value list to create records in JobHours with the following criteria:
1) I need it to be a drop-down rather than a pop-up so it will respond to auto-fill from the keyboard. A drop-down will show the secondary value (employee name) from a value list while dropped down, and will respond properly to keyboard autocomplete on the secondary value, but once you've made your selection, it only displays the primary value (employee ID).
2) I need it to display names, not IDs, at all times. The pop-up does this perfectly. However, it doesn't seem to respond to the keyboard for typing autocompletes.
3) I need to store the numeric ID rather than the name.
I know how to satisfy any two of these criteria at once, but that's all. The whole database is working beautifully otherwise. Is this behavior possible?
One common technique is to use two fields, one directly on top of the other.
On the bottom, put your JobHours::EmpID field. Set it up as the drop-down list with the value list that you've specified.
On top of the JobHours::EmpID field put the related Employee::EmpName field. Set the field so that it cannot be entered in browse or find mode.
Now your users will see the Employee Name, but when they click that click will go through the top field and into the Employee ID field where they will choose the name from the value list.
pft's solution is one that I have long used, but I do still find it inelegant because the user still sees an existing id number in the field when changing the value.
If the type-ahead is important, I would use the popup menu. Once the menu has been activated either by tabbing into it or by clicking into it, the user is able to type from the keyboard and the selection will change based on what's entered.
I came to this thread looking for a solution to this same issue (allowing the user to pick from a list, show their choice, but store a related value instead). For example, choose a plant species name from a dropdown, show the plant species name in the dropdown field, but have it store the taxonomic serial number (TSN; which is more likely to stay the same over the years). This is easy to do in MS Access, but took a litlte more messing around to do it in FMP12.
How I solved it:
I created two fields in the table that would be storing the values: Plant_TSN and Plant_SciName. A relationship must exist between the values in these two fields. In my case, I store a SciName for each TSN in a lookup table. I then created two fields in my layout, one for each new field.
For the value you wish to store (ex. Plant_TSN):
Make the corresponding layout field a dropdown and include the show/hide arrow. Edit the value list you will populate the dropdown with to show the second (reader friendly) column but store the first column value. In the layout shrink the field to only show the arrow.
For the field you wish the user to see (ex. Plant_SciName):
make the other layout field a Edit Box and prevent field entry in either Browse or Find mode. But it up against the dropdown arrow created in the previous step to make what looks like one field.
Finally, back in the first field (arrow-only drop down) write a script to push the user friendly number (Plant_SciName) to the edit box when the user-ugly (Plant_TSN) value is picked in the drop down. I used the OnObjectSave script trigger of the dropdown formatted field. Script should be something along the lines of 1) Freeze window, 2) Go to Related Record (based on relationship in lookup table 3) Set Field (i.e. the edit box) and 4) GotoLayout[original] to offset the Freeze.
Probably not an entirely clear explanation, but I bet you will get it on your third read through! I would have posted a screenshot, but I apparently need 10 "reputation points".
Cheers.