Full Version: Disable form after first use
UtterAccess Forums > MicrosoftŪ Access > Access Forms
Borborygmus
I want to allow data entry to a form on the first time it loads but on subsequent loads the form is to have no edits - just display the data initially entered. I have tried setting the fields 'Enabled' status to False and setting the form 'Allow edits' to No as part of the close form procedure but the form reverts to the original settings when re-loaded. Is there a way I can make the changes via VB in closing permanent?
Thanks.
bigdutch
In the on-open event make a dcount to see how many records are in the table the form is bound to. Hide the record selector in the form so only one record can be created/amended.
If dcount > 0 then
me.allowadditions = False
else
me.allowadditions = True
docmd.close
End If
JVanKirk
Welcome to UA!!
igDutch's post is right on, should work great. But that will lock it regardless of what user put in a record. Is this a multiuser db? If so, then your table will need to store what user entered the record and the DCount match criteria for that. If it isn't multiuser, then it sounds like this table will only ever hold one record, and that record will never, without administrator intervention, be able to be changed. What if there is a mistake realized after the form was closed?
Would be interested in hearing how this form is being used, what the record is.
J
Borborygmus
Thanks bigdutch and Jason,
The form is the opening form of the DB. There is a central database containing private information for each employee which is aggregated into various documents as reports (the output of the database). Each user has a DB on their own home directory referencing the master tables in the main database. Each 'satellite' DB has a table setting that user's permissions and this is the data for the form I want to lock after the first load. Permissions are set by the administrator using this form. After that the form opens with the caption "This user has access to the following files" ie the form reloads with the accessible files checked so the user can see what is and isn't available. I want that info to be visible but not editable.
Oused a workaround - since all the data to be entered is boolean and the default for all fields is 'no' I used a text box to sum the data entered and used the On Load event to set the Enabled and Locked status of the checkbox controls depending on whether the value in the text box = 0 or not. Not elegant but it works. Not sure what dcount does bigdutch but I will go and look it up now.
Thanks again
bigdutch
It sounds as if you have resolved your issue.
With the help of this website i have implemented a form level user access control based on the user network login credentials. Each user is then given read/write/deny access to each form or set of forms, all centrally controlled from the admin menu screen and the"satellite" db's would all be identical (and therefore easier to manage network wide) but all your controlling access is handled within the application referencing the tables.
JVanKirk
So the admin somewhere has a similiar form on his front end copy of the db and he can make edits right? Basically just the user can only update once...
I'm still interested in how you are handling this between different users. Do you have code checking who the current user is and locking the form based on current user? If not, then what happens if I'v enever used the db before and I use John Doe's computer to logon and access the db, will that form be locked because I'm using the front end on his machine??
J
bigdutch
Im not entirely clear what you are trying to do but i understand that your "satellite db" contains a table which populates the first form seen by the user. The table in question then lists a number of items ... im not clear what the user then does with this list so you will have to excuse me if i get wrong end of stick.
would suggest one table in the central db that holds all the user "permissions" with a userid field. Create a user table including their network login name and a userid. Look into fosusername function. When the "satellite db" (minus its local table) now opens this form (on open event) it detects the username, makes a dlookup on the user table for the userid and then requeries the datasource of the form to be filtered by the userid.
You could even disable allowedits or allowadditions on the form, and disable the controls so the user cannot add/edit the records shown. Another onopen event could then be "if userid = {adminuserid} then allow edits and additions and do not filter record source" so as the admin you then see all the records with add/edit permissions to make the changes.
The problem with your current setup is having to contol multiple client files, i have setup my network login script to copy my latest access file onto the user desktop and all the permissions are handled within the application by referencing the central database.
JVanKirk
Yeah, didn't realize there was a table in the front end of these databases...way too much overhead there...should have all tables in the backend.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.