Form / Subform Read Only after update?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am wanting to set up my invoice form/subform to be read only after
updating, but still allow for new invoices to be added without a password.

Thanks,

Brook
 
In the form's Current event:

Me.AllowEdits = Me.NewRecord
Me.Controls("sbfrmName").Form.AllowEdits = Me.NewRecord

The second line prevents edits in the subform. Replace sbfrmName with your
subform's name in the master form - it may not be the actual form name.

This will make the form and subform non-updateable after the first data
entry session for the record (after any action which causes the record to be
saved - such as moving to another record). If all the data is not entered,
or is entered incorrectly, you won't ever be able to change it again. Are
you sure this is what you want to do?

HTH,

Rob
 
Rob,

Thanks for the input..

Well, I guess it would be better to explain my over all inentions.

After an invoice is created, all form fields, I want it to be read only so
that our book keeper, along with a passwork will be able to login /enter the
form for edits and enter payments.

I have another person in the office that creates and mails the invoices.

Does this make sense?

Brook
 
Yes, it makes sense.

If you want a user with different privileges to be able to edit the data in
the form/subform, you can wrap the code I gave you in an If statement. For
example, if you have a function which returns true for a user who has
entered the password, you would put:

If Not PrivilegedUser then
Me.AllowEdits = Me.NewRecord
Me.Controls("sbfrmName").Form.AllowEdits = Me.NewRecord
End If

If you want to do it so that it's really secure, your best course would be
to use the Access security system for your application. However, it's not
for the faint-hearted or casual user. Are you are using it already - is
that where your passwords are implemented? You can do it using other
methods, but it's impossible to stop a determined & knowledgable person from
bypassing those methods. It may be adequate depending on your particular
situation.

HTH,

Rob
 
Rob,

I run a small office, so all I want at this point is to have one admin
password to access the "edit" mode of my form.

Can I do this without having to enter a password ever time I need to add a
new record?

Brook
 
What you asked originally was how to prevent editing of an existing record
after updating. The code I first posted will do that (assuming that by
"updating" you mean "initial entry"); it simply checks to see if it's a new
record; if so it allows edits, if not it disallows them (for everyone).
Anyone can add (and edit) a new record - until it is saved. It took no
account of passwords for anything - it simply would not allow anyone to edit
a record (or it's related records in the subform) after it was saved.

The If ... End If code that I later posted was an example of how you could
allow edit privileges to some user(s), via a "PrivilegedUser" function, for
which I included no details. How you choose to implement that is up to you,
and there are many ways you could do it. How is your current password
access implemented? Does it identify the user and their privileges within
the session, or does it ask for each action (not really a useable approach)?

You can (and should) set it up so that your user only needs to enter a
password once. However, you need to design you application taking that into
account all the way through, not for a particular form in a particular
circumstance. Applying a "band-aid" password system on a form-by-form (or
even worse, record-by record) basis is definitely not a good way to go.

Rob
 
Back
Top