Locking a table

is it possible to lock a table after adding 1 record so that no other records can be added? i am using fm8 with xp.
i have set the layout to not save records i have also created a custom menu so that add record is not available.
is this basically the only way to do it or is there another more fool proof way of locking a table?
kauakeaAsked:
Who is Participating?
 
billmercerConnect With a Mentor Commented:
I was just referring to using global fields instead of a separate table with a single record, not the number of layouts in your files. I don't know how your database looks, but if you had, for example,
  FirstName
  LastName
  Company
  City
Then you could create global fields called
 gFirstName
 gLastName
 gCompany
 gCity
and set their values with a script, instead of having to create a separate table to hold just one record.
Unless you're using an older version of FileMaker, where each file is a separate table?


 
0
 
lesouefCommented:
not to save record in a layout means, not automatic and asks confirmation, but does not mean cannot be saved.
if no script to create a new record + menu command removed, that's enough.
the fullproff way to do it is to remove records creation privilege in the account rights, and have a specific account to create it; but if it is the same user who is supposed to create the new record and then being disabled, you can't use that unless you relog the user under another name in a script after record creation... a bit hairy...
0
 
billmercerCommented:
If you want to allow the user to create only one record, but no more, you can do this by adding a field that can only have a single value.

Create a new field, and give it an auto-enter value that is a constant, such as 1.
Then set validation for the field to require unique value (no duplicates), and specify that this validation is performed always, not just on data entry. Set the field to prevent modification, also.

You can also add a custom error message to the validation that explains that you cannot add any more records

Now, if the table is empty, you can create one record.  But if you try to add a second record, the field validation won't allow it because you already have a record with that value, and you'll see an error message.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
lesouefCommented:
btw can we know the purpose of this? a table for only 1 record? if it 1 record per user, then it should be in the users table for instance...
0
 
kauakeaAuthor Commented:
i am setting a database up with about 50 forms. i want to use 1 layout for each form and just pull the fields from a record to fill in the fields. however there is no need to save the forms once they have been generated because once they are sent out that is the last that they will be accessed.
0
 
billmercerCommented:
I've occasionally used a single-record table with FM Server as a way to implement truly global variables that are persistent and shared by all users. That's a legitimate reason for doing something like this, but if you don't plan to keep the values, then it might be simpler to just use a set of global fields instead.


0
 
kauakeaAuthor Commented:
how do you mean use a set of global fields. i have set up each of the tables that hold the form layout field information as global. i actually have about 120 forms but many of them share the same layout via setting the form fields through a script. but since the forms differ in appearance and the fields dont layout the same on all of the forms i couldnt see how to further narrow the number of form layouts
0
 
lesouefCommented:
depends on the forms, sometimes, you can make them all with very few layouts by doing a large use of merge fields, merging say 50 fields in a single text field with represents the whole page
0
 
kauakeaAuthor Commented:
Actually, that is what i have. i should have clarified. i do have 3 tables that the layouts are bases on with all global fields that i set with the script at the time of form selection
0
 
billmercerCommented:
If the fields are all global, then it shouldn't matter how many records are in the table.

If you just want to keep people from adding records to this table for neatness, then just hide the options to create records.

If you really want to prevent anyone adding another record, you can enforce it with field validation as I mentioned above, but for novice users, it might be simpler to just ignore the whole issue. If someone somehow manages to create one anyway, it won't hurt anything, since the global fields won't be affected.

You could create an "initialize" script that deletes all records, then creates a new one and populates it with any desired values, then set the file to run this script automatically when opened.
 
0
 
kauakeaAuthor Commented:
i like the initialize script idea...it seems to be the answer.... keeps it clean and free of all worry!!! thanks
0
 
lesouefCommented:
you could even delete the created record right after printing.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.