Form Edit. Subform Edit. Lock/Unlock?

  • Thread starter Thread starter Igor via AccessMonster.com
  • Start date Start date
I

Igor via AccessMonster.com

greetings access avengers!

Heres my situation, can anyone make a suggestion? I have a form with several
fields that are used to search for records, on the same form are the results.
Within the resulting records, there is a 'notes' subform.

I need to be able to navigate the records and input the search fields, (all
running fine). The resulting records need to be uneditable including the
subform. Unless, I click my Edit button, making the records editable, or, I
click the New Note button, which would shift focus to the notes subform
(input todays date automatically, if possible) and allow for a new note. The
other thing is, if a new record is selected etc. the records revert to its
uneditable state.

Of course, the Allow Edits option doesn't work, Im about to try
locking/unlocking each field through code, (is this possible?) Im a wee bit
stuck, especially when it comes to code - Im a complete N00B, so any advice
is great.

Thanks to all..
 
This can be somewhat daunting.

If you want to unlock all fields for editing in the subform, you could use
this approach:
Locking bound controls on a form and subforms
at:
http://allenbrowne.com/ser-56.html

If you just want to allow new entries, but not edits, you could set the
subform's AllowEdits property to No, but AllowAdditions to Yes.
 
hi allen.. thanks for the link. I tried it, but no results.... The other side
of the problem, is that its not just a subform that I want to lock/unlock.
It is primarily selected fields on a form that I want to allow editing on.
 
Okay, you can do it with:
Me.[SomeControl].Locked = False
Me.[AnotherControl].Locked = False
and so on.
 
Got it got it got it got it got it got it..........

You are genius, Thanks Allen.
 
Bit premature there.... One last question on this topic?

Im trying to change the caption on the button from lock/unlock to
Edit/Editing

Ive tried changing it in the module:

On Error Resume Next
frm.cmdLock.Caption = IIf(bLock, "Editing", "Edit")
frm!rctlock.Visible = bLock = False

And the button:

Private Sub cmdLock_Click()

Dim bLock As Boolean
bLock = IIf(Me.cmdLock.Caption = "&Edit", True, False)
Call LockBoundControls(Me, bLock)

End Sub

But... this isn't running... can you help?
 
I don't see what's wrong with your approach.

Perhaps you could add a line that just says:
Stop
to the top of the procecure.
Then run it, and it will stop there.
Then press F8 to step through the procedure, and see what's going on. For
example, you can pause the mouse over a variable to see its value, or ask in
the Immediate Window (Ctrl+G).
 
Hi Allen, managed to change the button labels. Sorry for bugging you,
hopefully just a bullet answer if you could? My lock/unlock is running great,
just having trouble specifying a subform for it to ignore. I have tried your
suggestions on the link, and other forums. Could you explain to me where
exactly to place the subform name? Thankyou
 
Assuming a subform named Sub1:
Call LockBoundControls(Me, bLock, "Sub1")

To leave both Sub1 and Sub2 unaffected:
Call LockBoundControls(Me, bLock, "Sub1", "Sub2")
 
Hi Allen,

This is what Im trying:

Private Sub cmdLock_Click()

Dim bLock As Boolean
bLock = IIf(Me.cmdLock.Caption = "Edit&ing", True, False)
Call LockBoundControls(Me, bLock, "subfrmNotes")

End Sub

This is leaving subfrmnotes locked permanently. What I need is the module not
to include subfrmnotes at all, and run this subform from another button.
Thanks.
 
Managed to get what i needed by just deleting the acsubform case altogether..
Thanks for your help, and allowing me bug ya Allen.

Cheers mate.
 
Back
Top