How to make records read-only once entered in query? - sql

I have a form that a user will input data into, which will then send the added record to the backend of the database (I split the database so that the frontend is accessible to users while the backend is hidden). The frontend also includes a query with no filters, so that it will full portray the backend. This way, users can either input data via the form one record at a time, or add multiple records to the query (and therefore the backend) by copy/pasting from an excel sheet with a specified format (so that the data will be pasted in the same order as the fields of the query).
I want the user to not be able to edit the data/record once it is submitted, but I still want them to be able to view it in the query and/or paste multiple records in the "(New)" record row. Is there a way to make all entered records "read only" per se, but still have the ability to enter new data (i.e. make user unable to edit previous records, but be able to add new records)?
I used this forum as a reference, but the only solution I've come up with was to make the Recordset Type "Snapshot", which does all that I want, except it disables the ability to add a new record.
https://answers.microsoft.com/en-us/msoffice/forum/all/lock-the-entire-record-once-certain-textboxes-have/24f53c0a-2435-48b2-bf91-6713ff8b60ee
I've searched far and wide, but unfortunately haven't come up with anything. Any help would be greatly appreciated. Thank you!

Related

Access Form switches unintentionally between Datasets

I am rather new to coding an Access Application and I have a rather strange error I do not seem to be able to resolve.
I have multiple Forms which are used to write data to some tables. Basically one Form per table.
Mostly the forms are just used to show a selection of the data in the tables. To make sure that noone accidentally alters some data you have to press the button "alter" first, which unlocks the fields to alter the dataset. In one form, however, when you ppress the alter button it switches the dataset. I have one column which is an automated ID which serves as a primary key to distinguish the data from one another.
So when I am debugging the issue and print this ID (Debug.Print Forms(formName).Controls("ID")) it returns the ID of the data that I want to alter, but as soon as I access the data and change one field (Forms(formName).Controls("Column1") = "foo") and print the ID again the ID switched to a completely different dataset.
I have absolutely no clue how that could happen. There is no other code being processed in between. I have googled for multiple hours but have not found anything in this regard yet. Maybe I am just using not the right keywords.
Any help is highly appreciated.
Thanks in advance :)

Excel data validation list from closed worksheet

I have two Excel 2016 worksheets in the same folder. One is shipment form and the other master database for shipment history. This file also holds the list of "active customers", which obviously changes over time.
When user is creating a new shipment from the shipment form template, I want the customer to be selected from a drop-down list rather than filled in manually. While I'm able to set up standard data validation for a cell, the problem is that the list is maintained in a different Excel file (which, as stated, is in the same folder).
I was also able to set up name reference and have the list from the other spreadsheet available, however I still have one major usability obstacle - it only works when the user has opened the other file, I want to avoid that and just have the user work with shipment form template.
I.e. I'm looking for Excel to fetch the data validation list from another file without forcing the user to keep it open. What are my chances here?
Thanks!
You can use Power Query to get the data from the other file, even if it is closed. Power Query can get the list into the current spreadsheet and you can build the data validation on the Power Query result. You can configure the query to be refreshed when the file is opened, or the user can refresh it manually.

Access: Update and Append in same form

I am new to using the front end tools/VBA in access, but I am an advanced programmer.
I have a situation where I need to record the date, and method of commute, for a particular individual on a monthly basis. What I have done so far is programatically create a form that lists every day of the month and has a blank space next to it for the user to enter in how he commuted. User only has to fill in if he/she clean commuted. The question is, how do I:
1. Select Records that have already been entered for a month and populate them to a line on my form.
2. Show a blank space for a user to enter info on any date that is not associated with a record.
3. Update any records they changed.
4. Append any new records they enter in the blanks.
I need to do this all on one form so it is easy. I cannot ask the users to navigate.
I appreciate any suggestion that might lead me to a solution. Many thanks.
A standard bound form will do that.
Use the wizard to get started and specify your table as the source.
After much testing and working (strange not find examples of this), I have determined the way to do this.
Do not programmatically create the form.
a. Forms in Access are tied so closely to accesses "form binding" functionality that there are to many limitations trying to work with a programmatically created form. It's very difficult to do.
A better solution is to programmatically create a temporary table that has the correct data structure and bind the form to that temp table.
a. thus the only programmatic part of your form is setting the bindings. Once that is done, you can rely on the form binding in Access to work easily with your Select, Update, and Append functions.

How can multiple users run macros on a shared excel file?

I have an excel file on shared location where multiple users (4 in this case) are accessing the file at the same time.
This file has a “Master data” tab where all the base data is there and then there are 4 identical tabs (one for each user).
Each user tab has a set of filters using which the user will be able to extract relevant data based on the filters selected and can add or edit the rows. Once the user is done editing/adding rows, user will submit the data which will get updated/appended in the master data tab.
Users can select same or different options in the filters. I am facing errors when multiple users click on the submit button (macro) at the same time.
How can I resolve this?
Like some comments say, Excel is not designed for this...
But if you want to use Excel, i would recommend something like this:
Every time someone writes in the master data, you have to "lock" the master data tab. Just put a boolean in a cell, set it to true while you are writing and back to false as soon as you finished altering the master data tab.
Now, if someone wants to change values in the master data tab at the same time, check if the boolean is set to true. If yes, then you have to wait, if not, you can write the data.
Adding to Manuel Allenspach's response, my suggestion is to create a queue.
Queue should have a spot for user processing and other spots for users waiting.
Than, before running code, you should include a check to make sure no two users have their macros updating database at same time.

Display multiple query results in a list box?

My Access form has a list box that displays files the user has selected from an OpenFile dialog box. What I do is copy these list box files into a seperate folder on the network and I save this network path in a tblAttachments table. This table has a one-to-many relationship with my main table - tblIdeaDetails.
I created a query that selects records from the tblAttachments table:
SELECT tblAttachments.attachmentPath, tblAttachments.attachmentIdeaID
FROM tblAttachments
WHERE (((tblAttachments.attachmentIdeaID)=[Forms]![frmIdeaSubmission]![ideaID]));
My question is, how can I display the results of this query in that same list box when the user is navigating through the records (frmIdeaSubmission in this case, which is bound to the tblIdeaDetails table)? I've tried doing a requery, but I kept getting an "Out of stack" error.
There isn't a lot of information to go on with your question but let me see if I can help anyhow.
My suggestion is to isolate your problem and work it out before incorporating it into your project. Create a new access database and make a 'demo' of what you are trying to accomplish.
The reason I'm suggesting this is because an 'Out of Stack' error is memory related - could be related to database corruption - a whole myriad of reasons.
Microsoft Support lists a few reasons:
http://msdn.microsoft.com/en-us/library/aa264523(v=vs.60).aspx
As identified by the support page, it can be dependent upon a number of factors that are going to be present throughout the database.
All things being equal, if you have your listbox recordsource bound to the query you indicated - calling the requery method on the listbox object should do the trick. Changing the record should also force a requery if its bound to a data source.