MS Access 2010: How Can I Avoid Uneditable Query Results? - ms-access

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.

Related

Saving Master Table from Form built off Multiple Tables Microsoft Access

I am new to Microsoft Access and I am trying to build a Case Tracking system for our Employee Relations folks. I have a table for Employees and a table for Cases. They are linked by Employee ID. I also have a form to incorporates fields from both tables so they can fill out when a case comes in. How do I save the data on the form into a master case history table? I want to capture the employee data as it was when the case was added since departments, managers and other fields are dynamic for the Employee. My form includes:
Employee Table
Employee ID,
Company,
Job Family Group,
Cases Table
Case Number,
Case Date,
Case Type,
I know I can obviously write a query to join them, but it will show me the employee facts as they are as of the last data refresh. Any help you can provide would be greatly appreciated! Thank you again.
Actually, the way you approach this?
Well, you have a main form - employees.
Then, you have (make) a sub form of cases.
Now, that sub form can be a grid like display - perhaps you select (click) on a row to show + edit more details, or perhaps just a sub form as a grid (continues form) will suffice.
In other words, you don't make the form update both tables at once, but in fact use a main form, and a sub form.
Say, I have a table of Hotels. And I need/want to display hotel information, and THEN ALSO display people booked into that hotel?
so, I create a form based on table People. That table People of course has a column that relates back to the hotel they are booked to.
So, you get this:
So, each form STILL ALMOST ALWAYS will be based on ONE table. Don't try and make some multi-table join for the forms data source.
So, in your example?
you build a main form - employees - it can show all the information (and let you edit/add etc.) to that form.
For each case, from the case table?
Well, go off and build a 100% separate form for display of "case(s)".
Then save that form. Now, open up your employee form, and in design mode, simple drag + drop in the cases form into that form.
So, you don't actually base the form and its table on more then one table, but you combine multiple forms EACH based on their one respective table.
But, as above shows, the end result is a main form + sub form, and that gets you the relational database setup, and allows you to do this without having to write code.

How to Design Query for Two Tables Not Directly Related

With my limited knowledge of Access, I have been struggling to figure this one out.
I have 4 tables. tblJobDetails, tblDrawings, tblDrawingFixtureType and tblFixtureType. They are related to each other in that order.
What I have been trying to do is a query based from tblFixtureType. I want my users to have a datasheet where they can input all the fixture types for the given job, but keep them under that particular JobID. I have not had much luck in that department. All queries I have made either show every single type entered in the DB, or nothing.
The JobID is the PK for tblJobDetails and is a FK in tblDrawings. tblDrawingFixtureType is intermediate/junction table that is meant to hold quantities, but has DrawingID and TypeID as its FK's.
So how would I correctly build a query for my users to input all fixture types (designations), but keep them assigned/filtered under that particular JobID?
I am sure more info will probably be needed, so please ask.
You don't build a query to solve this problem. What you do is build a form based on each separate table.
In Access you model the parent to child relationships by using form + sub-form combos.
So, you might have a form that say lists out job (continues form).
You click on a row, and then launch a form with a nice display of the job details, and then in the sub form, you allow entry of tblDrawings.
The sub form will hook up the FK. And to edit/select the tblDrawingFixtureType, that drives a combo box in that sub form to select the fixture type, and it will save the PK of FixtureType in the one column.
All and any of each form (or even the sub form) is to be based on ONE table, and NOT a query. You don't edit data in tables, you build a form based on the table. If there is child records to add to that one record, then you build a sub form (and again, that sub form is based on ONE table).
Not only does this mean you don't have to create any queries, but you also don't have to write any code since when using a form + sub form, you get editing of related data that way.

Access add more than one record at a time using subform

Hello, so I need some help. The image attached is the form I'm working on. I got it working up until the point I can save that record and go back to my query where training records are and see it in there. The save button does not clear any info out of the form, but if I do change the id of 345 to say 346, it won't make a new line. It just rewrites over the 345 in the record. However, what I fully intend to do is have this store multiple records at once and the subform is where you can see what you're going to add once you hit save. This is my first big project, so speak in noob terms. Thanks!
I think I understand what you're trying to do and I'll use an example of a customer with multiple orders to explain how to use a subform to add multiple orders to the same person.
First, you want to have the Customer_ID and then a Product_ID. In the Product_ID table, make sure you have a field called "Customer_ID" which will act as the foreign key that will reference the Customer_ID field in the Customer table. When you add a subform to the Customer form, you set the "Master Field" and "Child Field" to the "Customer_ID". This will allow the subform to reference the Customer_ID field and maintain the relationship and a unique Product_ID (not Customer_ID) will be generated each time you add a record to the subform.
Select the subform and go to "Property Sheet>Data" and double-check the link in the master and child field.
Simple 1-to-many Employee-Task relationship
How the relationship should look like with the Subform
What the main form and subform should look like. You can do something similar with the Standard List Table based on the relationship you've established.

How to select multiple records and change their value at once

Here is my problem and I do not know where and how to start to search about this.
In a MS Access database users will have a list of records returned from a query. Let's say employees which are active (employed). This table has a related table let's say departments (related through departmentID in both table).
What I want to do is to make form (or something else which would do the same job), where user will select some records (probably with checkboxes associated with each record) and there will be a single combobox with department names. When user selects a department name, its departmentID should be saved into departmentID field of these records.
I have created a form with a query of active employees (form with multiple items). And put an extra field in Detail section with a checkbox. In Form footer I have a combobox with Department names and IDs (not shown to user), and a button to save values.
I have to now figure out, how to select all rows/records with a checked checkbox and update them. I am by the way familiar with VB and SQL.
I would appreciate any idea/knowledge on how to solve this.
An extra field in the Detail section won't help you if you don't link it with a data field in the displayed table. If you can do that, then you have simply to make a VBA function to update all selected rows, and refresh the recordset.
If you cannot modify your table, you'll have to create a new table with just the key columns of your master table, and manage it via VBA. Better to use the first option if you can, it pollutes your schema, but in most cases that won't be a problem for an Access database.

MS Access Report showing the id of the combobox and not the bound name column

The company I work for have an access database that is linked to a sql server table. The database is on a shared network location so it is used by lots of people in the company (with the annoying problem that only one person can use it at a time).
There are several forms that are used as a front end for the data and on one particular form there are combo boxes that are linked to other tables.
When a report is generated on the form the ID of the combobox is on the form (a GUID) and not the bound item of the combobox.
How can I get the bound items to appear on the form itself? The solution needs to be easy to do or something i can produce that can be regenerated as it's used by non technical people.
In order to make the database usable by many, simply give each user a copy of the front-end.
Forms should almost never be used for reports, the best thing to do is to build a query (the query design window will help) that references each of the relevant tables, for example, if the combobox contained a reference to person type and you might build a query like this for your report:
SELECT a.ID, a.SName, a.MainAddress, c.PersonType
FROM Addresses a
INNER JOIN PersonTypes c ''Or LEFT JOIN if data is missing
ON a.PersonTypeKey = c.PersonTypeKey
If this is not possible, perhaps you could explain in more detail exactly how the report is generated from the form.