A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

allowEdits



 
 
Thread Tools Display Modes
  #1  
Old August 11th, 2007, 05:39 AM posted to microsoft.public.access.reports
injanib via AccessMonster.com
external usenet poster
 
Posts: 108
Default allowEdits

I have my form property setup to AllowEdits=false.
When the form is opended in edits mode all fields are locked, which is what I
want so that records are not accidentaly edited. I have created a button that
runs the line, Me.AllowEdits=True, to unlock the fields so that a record can
be changed if need be. Once the changes are made I have another button the
should lock the fields again by running the line, Me.AllowEdits=false. But
the second button does not work. It does not lock the fields.
Here is the codes.

Private Sub Save_Click()
On Error GoTo Err_Save_Click

Me.AllowEdits = False

Exit_Save_Click:
Exit Sub

Err_Save_Click:
MsgBox Err.Description
Resume Exit_Save_Click

End Sub

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ports/200708/1

  #2  
Old August 11th, 2007, 09:43 AM posted to microsoft.public.access.reports
Allen Browne
external usenet poster
 
Posts: 11,706
Default allowEdits

If the form is dirty (has unsaved edits in progress) at the time you set
AllowEdits to False, Microsoft allows you to continue editing until that
record is saved. Otherwise you would have painted yourself into a corner.

Therefore you need to force the save before you turn AllowEdits off. Add the
line:
RunCommand acCmdSaveRecord
above your Me.AllowEdits = False.

Occassionally we see people doing very silly things such as dirtying the
form in its Current event, or the form's AfterUpdate event. In this case the
form is *always* dirty, so your attempt to set AllowEdits to False won't
work at all.

One of the problems with setting AllowEdits is that even unbound controls
become locked - not useful if use an unbound combo for navigation or
filtering. If you strike this problem, you can use the code in this link to
set the Locked property of the bound controls instead:
Locking bound controls on a form and subforms
at:
http://allenbrowne.com/ser-56.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"injanib via AccessMonster.com" u35551@uwe wrote in message
news:7684bd124c1e1@uwe...
I have my form property setup to AllowEdits=false.
When the form is opended in edits mode all fields are locked, which is
what I
want so that records are not accidentaly edited. I have created a button
that
runs the line, Me.AllowEdits=True, to unlock the fields so that a record
can
be changed if need be. Once the changes are made I have another button the
should lock the fields again by running the line, Me.AllowEdits=false. But
the second button does not work. It does not lock the fields.
Here is the codes.

Private Sub Save_Click()
On Error GoTo Err_Save_Click

Me.AllowEdits = False

Exit_Save_Click:
Exit Sub

Err_Save_Click:
MsgBox Err.Description
Resume Exit_Save_Click
End Sub


  #3  
Old August 11th, 2007, 05:14 PM posted to microsoft.public.access.reports
injanib via AccessMonster.com
external usenet poster
 
Posts: 108
Default allowEdits

Thanks,
Why do I get a Compile error when I enter the line
=LockBoundControls([Form],True)
in te onload event property of the file?

Allen Browne wrote:
If the form is dirty (has unsaved edits in progress) at the time you set
AllowEdits to False, Microsoft allows you to continue editing until that
record is saved. Otherwise you would have painted yourself into a corner.

Therefore you need to force the save before you turn AllowEdits off. Add the
line:
RunCommand acCmdSaveRecord
above your Me.AllowEdits = False.

Occassionally we see people doing very silly things such as dirtying the
form in its Current event, or the form's AfterUpdate event. In this case the
form is *always* dirty, so your attempt to set AllowEdits to False won't
work at all.

One of the problems with setting AllowEdits is that even unbound controls
become locked - not useful if use an unbound combo for navigation or
filtering. If you strike this problem, you can use the code in this link to
set the Locked property of the bound controls instead:
Locking bound controls on a form and subforms
at:
http://allenbrowne.com/ser-56.html

I have my form property setup to AllowEdits=false.
When the form is opended in edits mode all fields are locked, which is

[quoted text clipped - 20 lines]
Resume Exit_Save_Click
End Sub


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ports/200708/1

  #4  
Old August 12th, 2007, 05:56 AM posted to microsoft.public.access.reports
Allen Browne
external usenet poster
 
Posts: 11,706
Default allowEdits

Did you place the expression into the OnLoad *property* (i.e. in the
Properties box)?

Or did you place it in the code window (where it won't compile)?
If you want to use an event procedure instead of setting the property, try:
Call LockBoundControls(Me, True)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"injanib via AccessMonster.com" u35551@uwe wrote in message
news:768acdaa831c6@uwe...
Thanks,
Why do I get a Compile error when I enter the line
=LockBoundControls([Form],True)
in te onload event property of the file?

Allen Browne wrote:
If the form is dirty (has unsaved edits in progress) at the time you set
AllowEdits to False, Microsoft allows you to continue editing until that
record is saved. Otherwise you would have painted yourself into a corner.

Therefore you need to force the save before you turn AllowEdits off. Add
the
line:
RunCommand acCmdSaveRecord
above your Me.AllowEdits = False.

Occassionally we see people doing very silly things such as dirtying the
form in its Current event, or the form's AfterUpdate event. In this case
the
form is *always* dirty, so your attempt to set AllowEdits to False won't
work at all.

One of the problems with setting AllowEdits is that even unbound controls
become locked - not useful if use an unbound combo for navigation or
filtering. If you strike this problem, you can use the code in this link
to
set the Locked property of the bound controls instead:
Locking bound controls on a form and subforms
at:
http://allenbrowne.com/ser-56.html

I have my form property setup to AllowEdits=false.
When the form is opended in edits mode all fields are locked, which is

[quoted text clipped - 20 lines]
Resume Exit_Save_Click
End Sub


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ports/200708/1


  #5  
Old August 13th, 2007, 12:03 AM posted to microsoft.public.access.reports
injanib via AccessMonster.com
external usenet poster
 
Posts: 108
Default allowEdits

Allen,

I love how this method works. its great! Is it possible to have it so that
the form is not loaded locked when opened in add mode? I just wish I didn't
have to click the unlock button before I start entering new record.

Allen Browne wrote:
Did you place the expression into the OnLoad *property* (i.e. in the
Properties box)?

Or did you place it in the code window (where it won't compile)?
If you want to use an event procedure instead of setting the property, try:
Call LockBoundControls(Me, True)

Thanks,
Why do I get a Compile error when I enter the line

[quoted text clipped - 31 lines]
Resume Exit_Save_Click
End Sub


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ports/200708/1

  #6  
Old August 13th, 2007, 02:43 AM posted to microsoft.public.access.reports
Allen Browne
external usenet poster
 
Posts: 11,706
Default allowEdits

Sure. Just test to see if you are at a new record when the form loads.

Use this line of code in the event pocedure for the form's Load event:

Call LockBoundControls(Me, Not Me.NewRecord)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"injanib via AccessMonster.com" u35551@uwe wrote in message
news:769af35f49b7e@uwe...

I love how this method works. its great! Is it possible to have it so that
the form is not loaded locked when opened in add mode? I just wish I
didn't
have to click the unlock button before I start entering new record.

Allen Browne wrote:
Did you place the expression into the OnLoad *property* (i.e. in the
Properties box)?

Or did you place it in the code window (where it won't compile)?
If you want to use an event procedure instead of setting the property,
try:
Call LockBoundControls(Me, True)

Thanks,
Why do I get a Compile error when I enter the line

[quoted text clipped - 31 lines]
Resume Exit_Save_Click
End Sub


  #7  
Old August 13th, 2007, 03:06 AM posted to microsoft.public.access.reports
injanib via AccessMonster.com
external usenet poster
 
Posts: 108
Default allowEdits

Awesome,
One more thing. Can I make the button toggle between "Change" and "Save"?

Allen Browne wrote:
Sure. Just test to see if you are at a new record when the form loads.

Use this line of code in the event pocedure for the form's Load event:

Call LockBoundControls(Me, Not Me.NewRecord)

I love how this method works. its great! Is it possible to have it so that
the form is not loaded locked when opened in add mode? I just wish I

[quoted text clipped - 14 lines]
Resume Exit_Save_Click
End Sub


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ports/200708/1

  #8  
Old August 13th, 2007, 04:13 AM posted to microsoft.public.access.reports
Allen Browne
external usenet poster
 
Posts: 11,706
Default allowEdits

You can, but you will need to modify the code so that it tests for these
words in cmdLock_Click(), and assigns the desired words at the end of the
LockBoundControls() function instead of "Un&lock" and "&Lock".

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"injanib via AccessMonster.com" u35551@uwe wrote in message
news:769c8b6c4e48e@uwe...
Awesome,
One more thing. Can I make the button toggle between "Change" and "Save"?

Allen Browne wrote:
Sure. Just test to see if you are at a new record when the form loads.

Use this line of code in the event pocedure for the form's Load event:

Call LockBoundControls(Me, Not Me.NewRecord)

I love how this method works. its great! Is it possible to have it so
that
the form is not loaded locked when opened in add mode? I just wish I

[quoted text clipped - 14 lines]
Resume Exit_Save_Click
End Sub


  #9  
Old August 15th, 2007, 12:46 AM posted to microsoft.public.access.reports
[email protected]
external usenet poster
 
Posts: 1
Default allowEdits

On Aug 12, 11:13 pm, "Allen Browne"
wrote:
You can, but you will need to modify the code so that it tests for these
words in cmdLock_Click(), and assigns the desired words at the end of the
LockBoundControls() function instead of "Un&lock" and "&Lock".

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"injanib via AccessMonster.com" u35551@uwe wrote in messagenews:769c8b6c4e48e@uwe...



Awesome,
One more thing. Can I make the button toggle between "Change" and "Save"?


Allen Browne wrote:
Sure. Just test to see if you are at a new record when the form loads.


Use this line of code in the event pocedure for the form's Load event:


Call LockBoundControls(Me, Not Me.NewRecord)


I love how this method works. its great! Is it possible to have it so
that
the form is not loaded locked when opened in add mode? I just wish I
[quoted text clipped - 14 lines]
Resume Exit_Save_Click
End Sub- Hide quoted text -


- Show quoted text -


Thanks for your tip about forcing the save before changing the
AllowEdits property. It may be of interest to others to know that,
although the parent form sets the properties for subforms upon
startup, it does not do so when changing them from code. I found that
a fully-qualified reference to the subform was required to synchronize
their behavior.

-CLH333-

  #10  
Old August 15th, 2007, 08:03 PM posted to microsoft.public.access.reports
injanib via AccessMonster.com
external usenet poster
 
Posts: 108
Default allowEdits

Allen,
I use your codes on two forms. It works perfect on one of them that is loaded
in add mode from the switchboard. The other one opens in add mode by running
the line

DoCmd.OpenForm "FormName", , , acAdd

from a command button. Even though I have

Call LockBoundControls(Me, Not Me.NewRecord)

in the afterload property event of the form, it still opens the form in add
mode with all the controls locked.

Allen Browne wrote:
You can, but you will need to modify the code so that it tests for these
words in cmdLock_Click(), and assigns the desired words at the end of the
LockBoundControls() function instead of "Un&lock" and "&Lock".

Awesome,
One more thing. Can I make the button toggle between "Change" and "Save"?

[quoted text clipped - 11 lines]
Resume Exit_Save_Click
End Sub


--
Message posted via http://www.accessmonster.com

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:35 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.