Locking Entries

S

Sok Hong

Is there a way to code so that you only lock only
specified functions? I've tried

Private Sub Form_Current()
Dim bAllow As Boolean

bAllow = Me.NewRecord
Me.[SomeControl].Locked = bAllow
Me.[AnotherControl].Locked = bAllow
...
End Sub

however, this will only allow me to lock it when I am on
that particular entry. Once I go to a different entry and
refer back to it, the entry will be unlocked.
Anythoughts? Thanks.
..
 
S

SteveS

I'm not quite sure what you are trying to do. If you want
to allow additions and not allow edits, then change your
code to:

bAllow = Not Me.NewRecord
^^^

If me.NewRecord is true, then Not Me.NewRecord makes
bAllow = false, and

Me.[SomeControl].Locked = bAllow (bAllow = false)

makes the new record unlocked. If it is not a new record,
then Me.NewRecord is false, Not Me.NewRecord is true and

Me.[SomeControl].Locked = bAllow (bAllow = true)

makes the old record(s) locked.


You can make this the default for a form: in design view,
select the form, the data tab and set the Allow Edits to
NO and Allow Additions to YES. No code necessary.

HTH

Steve
 

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

Similar Threads


Top