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. |
|
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|