MS Access Multi User Selecting Different Records Concurrently - sql

In our multi-user Access environment, sometimes it is necessary to perform different actions on a group of records. In the Orders table, for example, a user may want to delete a group of orders, or to print out a group of records, etc. To accomplish this, in the Orders table, I created a boolean field called aSelect (the "a" is to avoid the "Select" SQL reserved keyword). On the Orders form, users can check off the orders which they want to process by clicking the checkbox for the aSelect field and then click "print", "delete", or whatever other operation. The code behind the form then says to process the operation on all Orders WHERE ASELECT=TRUE
The problem is that, (while it hasn't happened yet), the aSelect checkbox is bound to the underlying field in the table, and two users can change aSelect at the same time. So, suppose user A selects two records to delete, but before he hits the delete button, another user attempting to print a 100 records selects 100 records. The result will be that all 100 records will be deleted--not the intended result.
Any solutions or alternatives? This scenario plays out numerous times throughout the database. The Orders table is just one example.
Thanks,

Create a table with a username/userid column and an OrderID column.
When the user makes a selection, add a record to this table with the OrderID and username, then when running your query just join this selection table or use an IN() clause and filter by username.
Voila - user specific selections, which could be improved/expanded upon but this is my basic offering.

Related

Adding an uncertain amount of records

I am making a maintenance DB in Access. I have this form which shows the pending routines from a table:
There is a detail table for the parts of the machine on which the routine needs to be executed
I want that whenever I press the execute button on the form, one record gets added for the work orders table, and one record for each record the maintenance_detail table which belongs to the record in the maintenance table gets added to the work_orders_detail table. What would be an efficient way to do this?
Work orders and work orders detail tables:

Oracle APEX: Assign primary key as interactive grid ROWID, Use select Interactive Grid ROWID in SQL query

To preface -- I am as green as at gets.
I am tasked with building an app for internal org use. We have a DB with patient data, and in interface with a hospital electronic medical records system. patient data entered into the EMR is sent to us via interface to update the patient profile in our database. Partial matches require manual intervention.
Message is received in a table within a staging schema
attempts to match to existing patient
if there are only 'partial matches' a status is set to 'mismatch'
I want to:
Display a summary of all 'mismatch' status records. I want to use an interactive grid to select individual records.
Set ROWID of interactive grid rows to the respective primary key of the record in the staging table.
Use the selected Interactive Grid ROWID (user selects a specific record in the interactive grid) to select the matching primary key of the corresponding record in staging table to create SQL query to find potential matches within our DB. Potential matches are displayed in a second table.
Questions:
How do I set the rowID of an Interactive grid to the unique key column of the staging table?
--Some research shows I need a hidden item, is this correct?
How do I access a rowID that has been selected in the Interactive grid to use in a SQL query?
My humble thanks and appreciation
So, your question is a bit confusing, but as far as I understand it. You are getting some data from table A, trying to match it with table B. If it matches, it irrelevant for us. If a match is not found you want to show it so that it can be manually matched.
In apex in order to update a table, you need to select what is the primary key by which it will update the data. That is usually a column in the table, but it can also be rowid(just include it in the SQL like any other column).
What I would suggest for you from what I understand of your situation.
Display the mismatched rows in an interactive grid, with rowid as primary key. Then you will need to have a column by which you match, if these entries already have some sort of key by which you tried to match but failed, display that. And have that column be a PopupLOV so the user can edit what value is in that field and set it to the appropriate match. One thing you will need to be careful about. You are editing a Unique key, or perhaps even Primary key, you might get conflicts here. Even if you only display unmatched data in the LOV, you can still have a user editing multiple rows and trying to match two rows to the same value, that will fail with an error that isnt particularly user friendly.

How to enable multiple users to select different records from same table using MS Access front-end and MariaDB?

I have Microsoft Access front-end and MariaDB database. For example lets assume that there is only one table in database. I would like to enable that users can select some records using checkbox column to perform some operation on them. I could just add column 'check' to that table, but if I use connected recordset then particular record is marked for all users as well. If I use disconnected recordset than it is not editable.
What would be best approach to gain that functionality?
I am familiar with both DAO and ADO recordsets so either approach would be useful.
The simplest method is to use a multi-select listbox. When ready, build a list of the IDs of the selected rows and open the editing form having a recordsource like this:
Select * From YourTable Where ID In (2,5,7,9,22)
Alternatively, fill a temp table including a checkbox, and let the user check records as needed, then - as above or using an inner join - filter the true table.

Hide rows in a table from a user group

We have a table and multiple users access that table. However we would like to hide records in that table from a user group lets say GroupA. So that they don't see any records in their database except the ones that were created by them.
GroupA users should also have an option to add new records and edit their own record.
However, all other users (except groupA) should be able to see all records in the table.
We have SQL Server 2012.
Thanks.
You could create a view on the table for GroupA restricting records with appropriate criteria and grant SELECT to GroupA on view.
This is called row level security.
One common way is to allow access to the table only via a view.
(You can also write into a view).
The view must contain a WHERE statement which selects the rows the user is allowed to see.
BTW, be sure to use ORIGINAL_LOGIN when you reference to the current user.

Counting value list items in FileMaker

Please see link to FileMaker Pro 12 database I've created to illustrate my problem:
https://dl.dropboxusercontent.com/u/24821795/Example.fmp12
I want to count the number of times an Activity has been assigned to a Staff member, but there are a couple of things making it tricky (not impossible, I hope):
When the user performs a Find, the count should update to only include the found records.
The user can add to the list of activities.
In the example provided, SelfJoinCount and Activities::Count are not what I want - they both count Activity (e.g. Archery has been assigned to two staff members), but do not meet criteria 1. above.
Try performing a Find of Gender = M
The values of ReviewedCount (a summary field, counting Reviewed) change to 3, which is what I want.
The values of SelfJoinCount and Activities::Count do not change. In this case, I want them to change to 1 (i.e. One record with Ballooning, one record with Bird watching and one record with Archery in the found set).
I could create a calculation field with a 1 in it if the activity occurs and then a summary field counting that 1 for every single activity in the database, BUT this won't work because of criteria 2. above (also, there are a lot of activities).
Any ideas?
Ok, several problems you have here.
First, you need key values for your tables. This can easily be accomplished by creating a number field in each table. In the options, select auto-enter serial number, validation unique, not empty.
Now, you need a 3rd table for the join. This table will have the foreign key value for the Staff member as well as the foreign key for the activity.
You will want to have your Staff layout in form view, add a portal into the join table with they foreign key field for the activity. Create a popup or drop down list for activities (hint: if you want the name of the activity to show in the layout rather than its key, use a popup.) it needs to have they key value and display second field, all values, show only value from second field.
This will allow you to have a many to many relationship between the tables so that a single staff member can have many activities and an activity can have many staff members.
Now, if you want a count of each activity, you could of course create calculation fields in the staff table to count instances of each activity type, but I find that cumbersome and time consuming as well as requiring you to create TO's for each activity. What you really want to use is an ExecuteSQL() function. Some thing like this:
ExecuteSQL("
SELECT COUNT(J.FK_ActivityID)
FROM JoinTable J
WHERE J.FK_StaffID =?
Group by J.FK_ActivityID";"";"";Staff::PK_StaffID)
You can tweak that ExecuteSQL to include a specific activity, or leave it as it is an include them all. Up to you how you do it.
If it wasn't 7am and having had no sleep, I would mock up the file for you, but I think you would do better testing it and working on it on your own.