Checkbox per row in multi user access database - ms-access

I have the following situation:
I have a many to many relationship.
For example an Employee Table, an Course table, and an relation-table inbetween.
Now I want that the user can select out of the course table his courses in a dialog form.
That means that the underlying table for my continous form inside the dialog is the course table.
I want a checkbox in every row which indicates if the course is selected or not.
As I read it is not possible, to add an unbound checkbox, because they are just copies, and a select click would select all of them.
The solution would be to add an yes/no field to the underlying table courses.
But here I have the problem as I understand the matter, because I have several users using the database at the same time, that the underlying table will be updated if I click one checkbox and this update will select the value for all users which are using the dialog form concurrently, what I dont want.
So my question is, is there another solution to get a working checkbox per row in a multi user access database.
There are two solutions which I could imagine:
1) The underlying table will be the relation table and in this every possible combination between employee and course will be saved together with a yes/no field. (but that would be from a data view point quite horrible)
2) If the changes to a checkbox would not be directly written back to the database table, I could discard them on saving and manually insert the relation records in the relation table. (Is that possible?)
Thanks for any solution proposals

I see two good approaches:
1) This assumes that your database is split in a network backend + each user has a local frontend. This is the recommended setup for multi-user.
The frontend has a local table with Course_ID and a yes/no column.
A join of this local table with the Course table is the recordsource for your continuous form.
On loading, you copy the course ids into the local table, and set the existing relations to True.
On saving, you update the relation table.
2) Use a ListView control instead of a continuous form. It has inbuilt checkboxes. Loading and saving is done with a VBA loop.

Based on your description I assume your form has a LEFT/RIGHT JOIN in its data source where some ID field is null if the specific Course/Employee combination does not exists in your relation table. Let's call it LinkID. Then your checkbox should be something like =NOT ISNULL(LinkID). While you will not be able to use the OnClick event for the user to check/uncheck this way, you can use the onMouseDown event to see if the user clicked the checkbox and take action accordingly.
That way you don't need an "all combinations" relations table, no temporary table and no Yes/No field. If a record with the Course/Employee combination exists the box is checked, if it does not exists, it is not checked. Adding and removing courses is done by adding and deleting records from the relation table.

Have a look at this How to use unbound checkbox in a Continuous Subform - MS Access. A class that binds an unbound checkbox. Better than listbox, because you have a form with all its benefits (sort, filter, edit, append).

Related

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.

How to edit an existing record and not create a new one when using subforms in Access?

I have an access database that holds medical information. It holds quite a bit of information so i have grouped like fields together into individual tables and linked them using a common primary key. I have created a tab style form with subforms on each tab.
Some of these subforms contain fields from only one table, however there are a few subforms where i have included fields from more than one table.
For example, i have a table that holds blood transfusion data and a table that holds patient characteristics. Some Fields from the blood transfusion table and patient characteristics table are in the same subform, but I also have fields from both these tables in other subforms.
When i try to insert data into the sub-forms with fields from multiple tables i get the following errors..
update or cancelupdate without addnew or edit
and
The changes you requested to the table were not successful because
they would create duplicate values in the index, primary key or
relationship. Change the data in the field or fields that contain
duplicate data, remove the index, or redefine the index to permit
duplicate entries and try again.
From researching the problem i gather this is because access is trying to create a new record for both tables, but if a record has already been created with that primary key (from inserting data into a previous subform) it won't edit the existing record.
Does anyone know how to get access to edit the existing record in this instance instead of trying to add a new record? I have basic skills in VBA but this is a bit past my level of experience.
Any suggestions would be greatly appreciated.
I used have a whole long response about split forms instead but I was having a horrible time getting it to work. So here is my new and improved answer for using subforms.
Here is a link with sub form info if you want to brush up for your purposes https://support.office.com/en-us/article/Create-a-form-that-contains-a-subform-a-one-to-many-form-ddf3822f-8aba-49cb-831a-1e74d6f5f06b
Step 1
Make sure your main form is bound to the right table.
For my purposes I used a single combo box on my main form to search with. Make sure all the field parameters on your combo box are correct. This includes making sure the Row Source is correct and that you DO NOT have a control source entered.
Step 2
Don't press enter after making a selection in the combo box. To prevent people from hitting enter I created a dummy button at the bottom that says "Save and Refresh" but all it does it create a message window that pops up with "Save Successful". I find hitting enter creates the first error you keep getting. I'm not sure how to address this in a more sophisticated way yet.
Anything else that comes up I will add later.

Access continuous subform with checkboxes to store ticked values with mainforms id

I am a newbie to MS Access and trying make a productivity tracking program for where I work.
I have a main form that's bound to multiple subforms with ID and I need to add one more subform.
That subform is going to fetch all data from Personnel table in continuous form view, and I would like to add one checkbox and two more fields to each row in continuous form. The ticked rows needs to be stored in a different table.
Is there a way to do this?
You'll have to make the new table
Then make a query which relates the new table to the old and returns all of the values you want edited or displayed in your subform.
Make the subform based on this new query, since it is only 2 tables it should be editable if the join isn't to complicated.
Then using the Locked and Enabled Properties of the controls on your subform you can change what is editable and what isn't.
I will say that if this is a one to one relation between the new table and the eixisting table it would be much easier to just add the fields and deal with security/data reporting concerns elsewhere.
Attempt to clarify more
I am assuming your Personnel Table has a foreign key to the main table ID and a personnelID of its own. To have more fields that correspond to records in the Personnel table you need to create another table, we will call it CheckBoxes. Checkboxes needs to have a foreign key to the personnelID and then whatever fields and check boxes you require.
Then you need to make a Query that pulls from Personnel and CheckBoxes and joins them on the foreign key you have relating the two tables. Then make your continuous subform based on the query rather than a table.
Access makes the query creation really easy and this relaition should be simple enough to be able to edit through the query.
Again I would consider adding these fields to the personnel table rather than making your database more confusing than it has to be but that is up to you the designer.

Form Customization without VBA

We are rebuilding an asset database with Access 2013. We have 1 table with a Primary Key (Serial number of asset), and 22 other fields. We're designing a form to be used with the table so that we are not manually editing the table. The 'Status:' field explained later does not exist in the table; it is a user friendly way to show if the record exists or not.
The end goal is to have a form that will two cases. A user will enter a PK and hit the tab key. Then:
If the PK exists, it will pull the info from the other 22 fields and put them into the fields on the form (1:1) and update 'Status:' to 'Existing'.
If the PK does not exist, it will change the 'Status:' to 'New' and make all of the fields blank.
Most of the fields on the form will be Combo boxes. There will be a couple text fields and 1 date/time field.
Once a user is done with the form and has made any necessary changes, there will be a 'Save' button at the bottom that will write whatever is in the forms to the row indicated by the PK.
I have found partial solutions with the LostFocus() event in Access 2013 on the PK field of the form. I have little experience with MS Access, moderate experience with DBA, and no experience with VBA programming. I'm sure this solution can be done, my question is: can it be solved in a way other than hard coding the solutions? I also looked around for form building, but I couldn't find anything that worked how we need it so if there is a tool that can accomplish this, that is acceptable.
You might consider a form that contains a subform. Basically, you would design a form that has your PK input box and a subform. When the user hits tab (or a "Search" button), a query would run to search the table and display that record in the subform, or you could insert a new record if not. You may need to use a few queries and macros to link it all together, but it can be done code-free.

Many-To-Many MS Access Form With Checkboxes for All Options

I'm working on a Microsoft Access application for a summer camp to track which entities have signed up for which activities. There is a form for editing an entity's information. I would like to add to that form a list of all activity options. By each option should be a checkbox. When the checkbox by an option is checked, a entry should exist in the many-to-many junction table linking the entity with the activity.
Google offered some examples of building many-to-many forms but none (at least that I found) showing how to provide a full list of options with checkboxes.
How would I do this?
Database Table Layout:
Entity (EntityID, first name, last name, etc.)
Activity (ActivityID, activity name)
Entity_Activity (EntityID, ActivityID)
One way to do this:
Create a new entry in the Activity
table.
Manually insert one checkbox
per activity on the form.
Register
an onClick handler on each checkbox
that adds the appropriate row to the
junction table when tje checkbox is
checked and removes the appropriate
row when the checkbox is deselected.
I was hoping for an approach that didn't require manually laying out the form. With this method, every time a new activity is added, the form must be modified. Oh well....
Instead of check-boxes, the more natural way to do it with MS Access would be to have a list of activities (in a sub form) that each entity is signed up for. Activities would get added from a pull down list (and perhaps an Add button), and removed with a Remove button. With a clever query, you limit that list to only activities that the entity doesn't have yet.
Alternately, you could go with the checkboxes, but you'll have to modify your table layout slightly. Entity_Activity would need a third field (SignedUp, yes/no). You would then have to populate every Entity_Activity combination when you created a new Entity. However, if you should happen to add another Activity later on, you'll have to go through some hoops to get all the existing Entity's entries updated.