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 |
#21
|
|||
|
|||
Prevent edits - unexpected effects
I'm not sure I followed that question, but the code as posted operates on
the form you choose (whether main form or subform.) It loops through all controls on that form. If it finds a subform it calls itself recursive to lock/unlock the controls in the subform also. You don't need to know the names of the controls to lock/unlock. It figures them out. If you want to exempt some controls (i.e. there are some that should NOT be locked/unlocked), just enter the control names in quotes (no form name needed.) As it loops through the controls, it then ignores those controls. Since it passes the exception list down to the subforms as well, you can include the names of subform controls in the exception list. -- 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. "Access User" wrote in message ... Thanks, that's going to be a great help....how do you address the location/names of the control(s) in a sub-form of the 'parent' form which you want to exempt from locking? "Allen Browne" wrote: You place the code into the events of the form you want to lock. In code, use Me rather than [Form] I won't be able to follow up on this over the next week or two. Hopefully you will be able to take it from there. -- 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. "Access User" wrote in message ... I have created a 'parent' form into which I am placing the form where all this was going on before and I believe I ought to be putting the calls into the same events you cited in your response (below) into the 'parent' and removing them from the sub-form. Am I correct? Here are the calls as written Private Sub Form_AfterUpdate() Call LockBoundControls([Form], Nz(Me![tbl_MRA_Form].Form!Complete.Value, False), "Complete") End Sub Private Sub Form_Current() Call LockBoundControls([Form], Nz(Me![tbl_MRA_Form].Form!Complete.Value, False), "Complete") End Sub ...but....I can't seem to unlock the form when I click on the 'Complete' cmdbutton? "Allen Browne" wrote: Call the code in Form_Current, and Form_AfterUpdate, passing: Nz(Me.Completed.Value, False) If the check box is true, this will lock it. If the check box is false, this will unlock the record. If the check box is null (e.g. at a new record), it will unlock it. "Access User" wrote in message ... I've had a chance to implement this code and controls onto my form and I think I understand what it's doing and what it isn't doing. It seems to lock the user out from making any modifications to any records bound to the form/subform. What would like is to allow the user to see which records have been entered completely into the database. I currently have a checkbox control on it which is bound to a field in the underlying table and is called 'Complete'. Its label is red if it's been checked and green if it hasn't been and its status varies from one record to the next as the user scrolls through each record. But it fails to do what your cmdbutton did and that is prevent any edits to a record once the checkbox is selected. Thoughts? "Allen Browne" wrote: Setting AllowEdits to No for a form affects all controls on the form. Therefore the subform control is locked well. Even unbound controls are unusable. Here's an alternative approach: Locking bound controls on a form and subforms at: http://allenbrowne.com/ser-56.html This is a piece of code that leaves the form's AllowEdits property unchanged, but sets the Locked property of the bound controls instead. The unbound controls are therefore still usable. The code does lock the subforms too, but it accepts a list of controls to NOT lock. So, if you tell it not to lock your subform, it leaves it unchanged. "chris" wrote in message ... I have a form which I have locked for edits (in properties) to avoid accidental changes to data, and have place a command button on it to allow edits. There is a subform on this form which previously allowed users to add new associated records through the normal add record row at the bottom. However, when I chose to prevent edits on the main form I found that the add records row in the subform was greyed out. Clicking the command button to allow edits to the main form did not affect the subform. Has anyone got any idea why is might be happening and how I can overcome the problem? |
#22
|
|||
|
|||
Prevent edits - unexpected effects
Hi
Using the following now Private Sub Form_AfterUpdate() Call LockBoundControls(Me, Nz(Complete.Value, False), "Complete") End Sub Private Sub Form_Current() Call LockBoundControls(Me, Nz(Complete.Value, False), "Complete") End Sub I get an error 424 - object required? "Allen Browne" wrote: I'm not sure I followed that question, but the code as posted operates on the form you choose (whether main form or subform.) It loops through all controls on that form. If it finds a subform it calls itself recursive to lock/unlock the controls in the subform also. You don't need to know the names of the controls to lock/unlock. It figures them out. If you want to exempt some controls (i.e. there are some that should NOT be locked/unlocked), just enter the control names in quotes (no form name needed.) As it loops through the controls, it then ignores those controls. Since it passes the exception list down to the subforms as well, you can include the names of subform controls in the exception list. -- 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. "Access User" wrote in message ... Thanks, that's going to be a great help....how do you address the location/names of the control(s) in a sub-form of the 'parent' form which you want to exempt from locking? "Allen Browne" wrote: You place the code into the events of the form you want to lock. In code, use Me rather than [Form] I won't be able to follow up on this over the next week or two. Hopefully you will be able to take it from there. -- 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. "Access User" wrote in message ... I have created a 'parent' form into which I am placing the form where all this was going on before and I believe I ought to be putting the calls into the same events you cited in your response (below) into the 'parent' and removing them from the sub-form. Am I correct? Here are the calls as written Private Sub Form_AfterUpdate() Call LockBoundControls([Form], Nz(Me![tbl_MRA_Form].Form!Complete.Value, False), "Complete") End Sub Private Sub Form_Current() Call LockBoundControls([Form], Nz(Me![tbl_MRA_Form].Form!Complete.Value, False), "Complete") End Sub ...but....I can't seem to unlock the form when I click on the 'Complete' cmdbutton? "Allen Browne" wrote: Call the code in Form_Current, and Form_AfterUpdate, passing: Nz(Me.Completed.Value, False) If the check box is true, this will lock it. If the check box is false, this will unlock the record. If the check box is null (e.g. at a new record), it will unlock it. "Access User" wrote in message ... I've had a chance to implement this code and controls onto my form and I think I understand what it's doing and what it isn't doing. It seems to lock the user out from making any modifications to any records bound to the form/subform. What would like is to allow the user to see which records have been entered completely into the database. I currently have a checkbox control on it which is bound to a field in the underlying table and is called 'Complete'. Its label is red if it's been checked and green if it hasn't been and its status varies from one record to the next as the user scrolls through each record. But it fails to do what your cmdbutton did and that is prevent any edits to a record once the checkbox is selected. Thoughts? "Allen Browne" wrote: Setting AllowEdits to No for a form affects all controls on the form. Therefore the subform control is locked well. Even unbound controls are unusable. Here's an alternative approach: Locking bound controls on a form and subforms at: http://allenbrowne.com/ser-56.html This is a piece of code that leaves the form's AllowEdits property unchanged, but sets the Locked property of the bound controls instead. The unbound controls are therefore still usable. The code does lock the subforms too, but it accepts a list of controls to NOT lock. So, if you tell it not to lock your subform, it leaves it unchanged. "chris" wrote in message ... I have a form which I have locked for edits (in properties) to avoid accidental changes to data, and have place a command button on it to allow edits. There is a subform on this form which previously allowed users to add new associated records through the normal add record row at the bottom. However, when I chose to prevent edits on the main form I found that the add records row in the subform was greyed out. Clicking the command button to allow edits to the main form did not affect the subform. Has anyone got any idea why is might be happening and how I can overcome the problem? |
#23
|
|||
|
|||
Prevent edits - unexpected effects
"Access User" wrote in message
... Using the following now Private Sub Form_AfterUpdate() Call LockBoundControls(Me, Nz(Complete.Value, False), "Complete") End Sub Private Sub Form_Current() Call LockBoundControls(Me, Nz(Complete.Value, False), "Complete") End Sub I get an error 424 - object required? Will have to let you do your own debugging. -- 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. |
#24
|
|||
|
|||
Prevent edits - unexpected effects
not being the old hand with this product, got any suggestions re how to
tackle it? "Allen Browne" wrote: "Access User" wrote in message ... Using the following now Private Sub Form_AfterUpdate() Call LockBoundControls(Me, Nz(Complete.Value, False), "Complete") End Sub Private Sub Form_Current() Call LockBoundControls(Me, Nz(Complete.Value, False), "Complete") End Sub I get an error 424 - object required? Will have to let you do your own debugging. -- 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. |
Thread Tools | |
Display Modes | |
|
|