AllowEdits Question

S

Secret Squirrel

I have a control on my form called txtDateClosed. When this is filled it
triggers the form to not allow edits to that particular record. How can I
keep this the way it is but allow edits to one control on my form header? I
have a control on my form header I use to search for a particular record. I
want to be able to use this control even if the record I'm on is locked.
 
S

Secret Squirrel

Thanks Graham. Appreciate it. I will follow the code Allen has.

SS

Graham Mandeno said:
Hi SS

Unfortunately you will need to lock all the controls individually *except*
the one you want to edit. Allen Browne has some nice code for doing that
here:
http://allenbrowne.com/ser-56.html
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

Secret Squirrel said:
I have a control on my form called txtDateClosed. When this is filled it
triggers the form to not allow edits to that particular record. How can I
keep this the way it is but allow edits to one control on my form header?
I
have a control on my form header I use to search for a particular record.
I
want to be able to use this control even if the record I'm on is locked.
 
S

Secret Squirrel

Hi Graham,

Quick question for you. I'm using Allen's code to lock/unlock my form but
I'm setting it up to do it based on whether the "txtDateClosed" field is null
or not. I put this code into my OnCurrent event so it will lock records that
have a date closed and unlock records that do not.

Dim bLock As Boolean

If IsNull([txtDateClosed]) Then
bLock = IIf(Me.cmdUnlock.Caption = "&Lock", True, False)
Call LockBoundControls(Me, bLock)
Else
Call LockBoundControls([Form], True)
End If

But the problem is I'm getting an error everytime I open the form.

Error 2455 - You entered an expression that has an invalid reference to the
property Form/Report

When I remove this portion of the above code I no longer get the error
message but it locks all the records even if the "txtDateClosed" is null

bLock = IIf(Me.cmdUnlock.Caption = "&Lock", True, False)
Call LockBoundControls(Me, bLock)

The "bLock" is referring to the command button on my form that I added per
his instructions. Could that be where the problem is?

SS

Graham Mandeno said:
Hi SS

Unfortunately you will need to lock all the controls individually *except*
the one you want to edit. Allen Browne has some nice code for doing that
here:
http://allenbrowne.com/ser-56.html
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

Secret Squirrel said:
I have a control on my form called txtDateClosed. When this is filled it
triggers the form to not allow edits to that particular record. How can I
keep this the way it is but allow edits to one control on my form header?
I
have a control on my form header I use to search for a particular record.
I
want to be able to use this control even if the record I'm on is locked.
 
G

Graham Mandeno

Hi SS

It seems the problem is with this line:
Call LockBoundControls([Form], True)

A form should refer to itself as [Form] from the property sheets of its own
objects, but should refer to itself as Me from its own class module.

So, say you had a command button to lock the controls and that was all it
did. You could put the following for its OnClick property:
=LockBoundControls([Form], True)

But if you wanted to do the same thing within the buttons event procedure,
you would need:
Call LockBoundControls(Me, True)

Also, your use of IIf is redundant. Instead of:
<Boolean variable> = IIf( <Boolean expression>, True, False )
you can just say:
<Boolean variable> = <Boolean expression>

So, in your case:
bLock = (Me.cmdUnlock.Caption = "&Lock")

--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

Secret Squirrel said:
Hi Graham,

Quick question for you. I'm using Allen's code to lock/unlock my form but
I'm setting it up to do it based on whether the "txtDateClosed" field is
null
or not. I put this code into my OnCurrent event so it will lock records
that
have a date closed and unlock records that do not.

Dim bLock As Boolean

If IsNull([txtDateClosed]) Then
bLock = IIf(Me.cmdUnlock.Caption = "&Lock", True, False)
Call LockBoundControls(Me, bLock)
Else
Call LockBoundControls([Form], True)
End If

But the problem is I'm getting an error everytime I open the form.

Error 2455 - You entered an expression that has an invalid reference to
the
property Form/Report

When I remove this portion of the above code I no longer get the error
message but it locks all the records even if the "txtDateClosed" is null

bLock = IIf(Me.cmdUnlock.Caption = "&Lock", True, False)
Call LockBoundControls(Me, bLock)

The "bLock" is referring to the command button on my form that I added per
his instructions. Could that be where the problem is?

SS

Graham Mandeno said:
Hi SS

Unfortunately you will need to lock all the controls individually
*except*
the one you want to edit. Allen Browne has some nice code for doing that
here:
http://allenbrowne.com/ser-56.html
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

Secret Squirrel said:
I have a control on my form called txtDateClosed. When this is filled it
triggers the form to not allow edits to that particular record. How can
I
keep this the way it is but allow edits to one control on my form
header?
I
have a control on my form header I use to search for a particular
record.
I
want to be able to use this control even if the record I'm on is
locked.
 

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