i've tried creating a subform (also a subdata sheet).. to be able to track which employee has trained on what document type. I want to be able to run queries/report that i can sort either by employee name or see all employees who trained on a specific document type.
If i have 2 tables, 1 with employee names (only 27 records), and 1 with document types (about 160 records).. how do i create a relationship since the autoID numbers (or primary keys) are not the same amount?
I want to be able to have a form, that displays a datasheet where i can enter employee names and training completion dates. There could be multiple employees who trained on the same document. So far, i've only been able to link 1 employee per 1 document.
Any feedback is very much appreciated!!
Thank you!
This is a many-to-many relationship and requires a third "junction" table: EmpTrng.
Data entry options:
one form bound to EmpTrng with comboboxes to select employee and training
form/subform arrangement - main form bound to Employees and subform bound to junction table with a combobox to select document
form/subform arrangement - main form bound to Documents and subform bound to junction table with a combobox to select employee
Related
I have a form where you choose the employees in a dropdown continous form.(From tblEmployee) that worked this week and store them in TSLabor table. In another form I track what activities were done during the days of the week (could have multiple activities for any given day) in tblActivities. In this form I have a sub form list of all the employees who are in tsLabor for this week. This way the user can input the hours for each employee. (Not all employees will have hours in every activity, but I can handle zero hours.) These records are stored in tsActivityLabor. I add a record for each employee in the TSLabor table with the activityID it each time a new activity record is created.
User can not add/delete in the subfom, but they can in the First form. My issue is how do I add/Delete from the tsActivityLabor table (for each activityID) when an employee is added/deleted from the First form.
I need to check to see if the employee has a record for each activityID for that week. If not add it.
Right now I create a record set of activityIDs for the week from tblActivities. I then create another recordset from the tblTSLabor of all the employees in that week. I then take each ActivityID from the first recordset and create a third recordset of all the employees for that ActivityID in the tsActivityLabor table. I then verify that each employee from the second recordset has a record in the third recordset.
There has to be a quicker way of doing this but I can't figure it out. One thought is to create an update query that could look at the tsActivityLabor table and verify that there is an employee record for each employee for each activity. Researched but can't find any examples of a query like this. any help would be appreciated.
Adolph
In short when queries underlying forms get complicated Access doesn't know how to update the tables and so chooses not to try.
https://learn.microsoft.com/en-us/office/troubleshoot/access/errors-updating-query-form-data
This is not a problem for your case as the TSLabor table in your example can be replaced by a date column in the TSActivityLabor Table. Access is supposed to be user friendly so I'm going to suggest a workflow that lets access help. here is an example:
create the following tables and hook up the relationships under the Database Tools-Relationships Tab.
Now click on any table and hit create form and access will create a working form which properly updates the tables. Here is the form after hitting the Employee table:
Because we set up the relationships in advance Access automatically added the many side of the relationship as a subform. Play with the highlighted record selectors to see how to cycle through records and add new ones.
Next we Start improving the forms. In the EmployeeActivity Form I Replaced Foreign Keys with combo boxes, removed the ID which the user should never see and added an unbound combobox to filter the records.
P.S. if the weekly Activities is still a thing Relate Activities to employees through a weeklyactivities table (a type of super many to many relationship).
I've coded my entire database to rely on recordsets and updating those recordsets on click of record IDs within other forms. Then I discovered that I can't edit the records from the datasheet. So I need an alternative.
My database consists of the following tables: Customer, Address, Order, Details, Contact and Misc. Each of these tables has a PK which is stored in a table called Master_Bridge which constructs a unique combination of all the PKs.
I have a form which includes each of these tables as a subform. The user begins at the Customer subform. When they click the Customer_ID, the Address table needs to filter based on where that Customer_ID exists within the Master_Bridge.
I was hoping to store each of the IDs into a recordset, or an array of some type, and translate each of those values into the filter. Admittedly, my VBA isn't good enough that I know how to do that.
I also tried a nested select in the recordsource of the Customer form, where I selected all of the Address_IDs. Again, couldn't edit.
Do you folks have any suggestions on how to proceed with this? I'll also need the click of Address_ID to filter the Order form by using both the Customer_ID and the Address_ID. The rest of the tables/forms will utilize the above 3 IDs.
I am creating a sales database for a small charity in MS ACCESS which should allow a salesperson to enter a Sale and then pull reports etc.. The entry form for the sale (testsales) should create an entry in the sales table. This table has a foreign key for the agency table which in turn stores all the referral agencies we work with.
I have put the combobox for the agency name selection in a subform.
Unfortunately each time I save a sale with a value in the combobox selected, the dublicate value is added to the agency table.
Thanks in advance
Database relations
Salesentry form with subform
If there is anything I should add please let me know.
In your case you can use only combobox or listbox with source of rows from query instead of using subform.
You will have to query AgencyID and AgencyName, make the Bound column AgencyID (1 if you query AgencyID first), but set the width of AgencyID in combobox/listbox to 0 to not show it for users.
I have built a form called projects and an employees table in access 2007. One of the fields on the form is called installers sent. I would like the installers sent box to auto populate based on the first name of the employee in the employees table. How can this be done? If I need to put in more clarification, I will. This is my first time working with access so I'm not really sure what i'm doing
Edit: I'm not sure what you mean by code. But basically, I have a table that keeps track of employee info and another table to keep track of project details. Both also have an associated form for easy data entry. On the projects table, I have a field for which installers were sent to the project site. Obviously, all these individuals are also employees. What i'd like to be able to do is have employee information auto populate as the user types in an employees first name. I'm assuming I can set up a query to do this, but I'm not sure how
Your question is still somewhat confusing to me in that you only mention two tables but multiple installers (employees). This suggests that you need three tables:
Projects
ProjectID
Employees
EmployeeID
ProjectsEmployees
ProjectID
EmployeeID
This could then be set up as a main form and subform: Binding a combobox in subform Access (prettier subform Difficult cross-tab query)
An alternative is a listbox with the row source set to:
SELECT EmployeeName FROM Employees
INNER JOIN ProjectsEmployees
ON Employees.EmployeeID = ProjectsEmployees.EmployeeID
WHERE ProjectsEmployees.ProjectID = Forms!TheCurrentFormName!ProjectID
I am working on my first Access 2010 database and have run into a problem editing the recordset returned from a query. This excellent blog entry details several scenarios which can result in uneditable query results. I believe my query results are not editable because my query has a Cartesian Join.
I'm not sure how to avoid this, however. The three tables involved are:
episodes
Individual television episodes
Primary key: "episode_id"
aridates
Individual airdates for a given episode
Primary key: "airdate_id"
Related to "episodes" by "airdate_episode_id"
startdates
Individual download start-dates for a given episode
i.e. when a given episode will be available to download
Primary key: "startdate_id"
Related to "episodes" by "startdate_episode_id"
So, there is no (and I think can be no) direct relationship between airdates and startdates. However, this makes the query:
SELECT episodes.episode_id, episodes.episode_number, episodes.episode_title, airdates.airdate_region_id, airdates.airdate_date
FROM (episodes LEFT JOIN airdates ON episodes.episode_id = airdates.airdate_episode_id) LEFT JOIN startdates ON episodes.episode_id = startdates.startdate_episode_id;
return a recordset which is not editable. I need to be able to see the episode name and number along with the airdate in order to enter a startdate (episodes can not be made available for download before they have aired). So essentially, in this view I only need to be able to edit "startdates.stardate_date".
Thanks in advance for any suggestions... a screenshot of the relationship in question can be seen here.
Create this query:
SELECT
episodes.episode_id,
episodes.episode_number,
episodes.episode_title,
airdates.airdate_region_id,
airdates.airdate_date
FROM
episodes LEFT JOIN airdates
ON episodes.episode_id = airdates.airdate_episode_id;
Use it as the recordsource for a new form. Then create another form which uses a query of only the startdates table as its record source.
Add the second form as a subform to the first form. On the property sheet for the subform control, make the link master field episode_id and the link child field startdate_episode_id.
If you are successful, the subform will display startdates rows where the startdate_episode_id matches the episode_id of the main form's current record. And if you add a new row in the subform, its startdate_episode_id will "inherit" the episode_id from the main form.
I emphasized control earlier because that point can be confusing. The subform control is a member of the main form's controls collection, and the subform control contains the subform. You must find the link master/child field properties on the subform control, not the actual subform itself.