Locking records if a flag is set

M

Martin

I have a simple order management database, in which I wish to 'lock' (prevent
edits on) a record if a flag is set to true. The flag is set to true if the
status of the order is set to either closed or cancelled.

How can I do this?
 
J

Jeff Boyce

Martin

Assuming that all user interaction with data is passing through forms (this
is the preferred approach), one way to do this would be to have Access cycle
through all the controls (textbox, listbox, combobox) on the form, setting
the .Enabled property = whatever value is in the "flag" field.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

Jeff Boyce

Martin

I take that back... I reread your post.

You'd need to set .Enable = Not <value of your flag field>

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

Jamie Collins

I have a simple order management database, in which I wish to 'lock' (prevent
edits on) a record if a flag is set to true. The flag is set to true if the
status of the order is set to either closed or cancelled.

How can I do this?

Create a VIEW (Access Query object comprising a non-parameterized
SELECT query) with a search condition e.g. ANSI-92 Query Mode syntax:

CREATE VIEW OrdersOpen AS
SELECT OrderID, CustomerID, OrderDate
FROM Orders
WHERE is_closed_or_cancelled = TRUE;

(or manually create a Query object, omitting the first "CREATE VIEW"
line of course).

Revoke the 'update' (and perhaps the 'select') privileges from the
base table and grant them instead to the VIEW; this way, changes can
only be performed via the VIEW, hence can only be performed on non-
closed/cancelled rows.

Jamie.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top