Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Restrict table to one record? 2

Status
Not open for further replies.

Goaltender

Programmer
Jun 14, 2003
7
CA
Hi Everyone,

How do you restrict a table to one record. This is a table that is used to identify the owner of the database. A registration table that can only have one owner.

If you know of another thread that can answer this question please direct me to it or please answer if you understand my question.

Thanks

Jim
"Thanks for comin'out...."
 
I don't know how to do this structurally... but just off top of head solution:

whatever mechanism adds the new record, before insertion, do a record count. if count = 1 then prompt user to either "update" existing record or forbid action.
 
Suppose the record is accessed via a form?
Set AllowDeletion and AllowAddition to False.

Have a nice summer,
Hans
 
Thanks for your help.

Hans, It works like a charm.
Very Helpful!

Thanks Jim
 
Don't use a table at all. Make this information a property of the mdb.

Peleg
PelegNOSPAM@PStrauss.net
 
If this is data that will not be modified, use Global Constants instead of a table/record.

Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
It is obvious that for total static data, (Global) constants are best. Point for you Larry.

If the data has to be changed by the user, then I think a one record table is far better then Properties, as you still have the possibility to make relations in a query or use it in a union with a table.

This union solution is nice when you want to give the user the possibility to choose between a (for example) country and "ALL".

Have a nice time,
Hans
 
It's actually quite easy to create a table that can only have one record. most of my databases have a table called tblConstant. It's a bit of a misnomer because, as someone else pointed out, if the data were fully constant, using constants would be faster. However there are often things that change only once in a blue moon, but they do change. And for these, I use tblConstant.

tblConstant has whatever fields I need to retrieve data from and one more field that I call OnlyOneRecord. This is a numeric field (byte will do) with a default value of 1, a validation rule of = 1, and a unique index on it. There's no way to have more than one record that meets the criteria of = 1 and is unique, so there's never more than one record.

Jeremy

PS: Confession: because it's so convenient to have this table, which collects important data that I'll use throughout the database, I don't actually use constants at all--I suffer through the performance hit of loading up a recodrset at the start of the application and using global variables from then on.

==
Jeremy Wallace
AlphaBet City Dataworks
Professional Development for Clients Large and Small

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top