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
|
|||
|
|||
Locking Fields
I have a form which I want to lock all the fields unless the Edit button is
clicked. I didn't want to use the onload event on the form because then it will only apply when it loads the form. I used the following code for the Forms AfterUpdate Event: Private Sub Form_AfterUpdate() Dim c As Control On Error Resume Next For Each c In Me.Controls c.Locked = True Next End Sub and the following for the Edit Button Click Event: Private Sub Edit_Record_Click() Dim c As Control On Error Resume Next For Each c In Me.Controls c.Locked = False Next End Sub The problem I'm having is that when I first open the form and add a new record, then click the add new record button I can't just start typing, I first have to click on the edit button and then start typing into the fileds. Is there a way to fix that? Also, if I click on the edit button and I don't edit the record then click the next button, it doesn't end the command until I change a record. Thank you. |
#2
|
|||
|
|||
Locking Fields
Could you get away with just setting the form's AllowEdits property to No,
while leaving AddAdditions as Yes? That may not be enough if you have unbound controls you want to edit, subforms that need to be set too, or selected controls that should not be unlocked. For those cases, see: 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. "Mya48" wrote in message ... I have a form which I want to lock all the fields unless the Edit button is clicked. I didn't want to use the onload event on the form because then it will only apply when it loads the form. I used the following code for the Forms AfterUpdate Event: Private Sub Form_AfterUpdate() Dim c As Control On Error Resume Next For Each c In Me.Controls c.Locked = True Next End Sub and the following for the Edit Button Click Event: Private Sub Edit_Record_Click() Dim c As Control On Error Resume Next For Each c In Me.Controls c.Locked = False Next End Sub The problem I'm having is that when I first open the form and add a new record, then click the add new record button I can't just start typing, I first have to click on the edit button and then start typing into the fileds. Is there a way to fix that? Also, if I click on the edit button and I don't edit the record then click the next button, it doesn't end the command until I change a record. Thank you. |
#3
|
|||
|
|||
Locking Fields
You could try me.allowedits = me.newrecord on the load event. Your edit button will then be me.allowedits = true. Ian King "Mya48" wrote in message ... I have a form which I want to lock all the fields unless the Edit button is clicked. I didn't want to use the onload event on the form because then it will only apply when it loads the form. I used the following code for the Forms AfterUpdate Event: Private Sub Form_AfterUpdate() Dim c As Control On Error Resume Next For Each c In Me.Controls c.Locked = True Next End Sub and the following for the Edit Button Click Event: Private Sub Edit_Record_Click() Dim c As Control On Error Resume Next For Each c In Me.Controls c.Locked = False Next End Sub The problem I'm having is that when I first open the form and add a new record, then click the add new record button I can't just start typing, I first have to click on the edit button and then start typing into the fileds. Is there a way to fix that? Also, if I click on the edit button and I don't edit the record then click the next button, it doesn't end the command until I change a record. Thank you. |
#4
|
|||
|
|||
Locking Fields
If I set the AllowEdits property to No, my edit button doesn't work at all.
I followed step by step the instructions from the web page you suggested and I'm getting a compile error saying: Expected: Line number or label or statement or end of statement It's giving me the error on this statement Private Sub Form_Load() =LockBoundControls([Form],True) End Sub Thanks. "Allen Browne" wrote: Could you get away with just setting the form's AllowEdits property to No, while leaving AddAdditions as Yes? That may not be enough if you have unbound controls you want to edit, subforms that need to be set too, or selected controls that should not be unlocked. For those cases, see: 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. "Mya48" wrote in message ... I have a form which I want to lock all the fields unless the Edit button is clicked. I didn't want to use the onload event on the form because then it will only apply when it loads the form. I used the following code for the Forms AfterUpdate Event: Private Sub Form_AfterUpdate() Dim c As Control On Error Resume Next For Each c In Me.Controls c.Locked = True Next End Sub and the following for the Edit Button Click Event: Private Sub Edit_Record_Click() Dim c As Control On Error Resume Next For Each c In Me.Controls c.Locked = False Next End Sub The problem I'm having is that when I first open the form and add a new record, then click the add new record button I can't just start typing, I first have to click on the edit button and then start typing into the fileds. Is there a way to fix that? Also, if I click on the edit button and I don't edit the record then click the next button, it doesn't end the command until I change a record. Thank you. |
#5
|
|||
|
|||
Locking Fields
Put the statement into the On Load property.
If you want to use a line in the event procedure instead, it would be: Call LockBoundControls(Me, True) If you used a command button (not a toggle button), it should be possible to click it even if the form's AllowEdits property is No. -- 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. "Mya48" wrote in message ... If I set the AllowEdits property to No, my edit button doesn't work at all. I followed step by step the instructions from the web page you suggested and I'm getting a compile error saying: Expected: Line number or label or statement or end of statement It's giving me the error on this statement Private Sub Form_Load() =LockBoundControls([Form],True) End Sub Thanks. "Allen Browne" wrote: Could you get away with just setting the form's AllowEdits property to No, while leaving AddAdditions as Yes? That may not be enough if you have unbound controls you want to edit, subforms that need to be set too, or selected controls that should not be unlocked. For those cases, see: Locking bound controls on a form and subforms. at: http://allenbrowne.com/ser-56.html "Mya48" wrote in message ... I have a form which I want to lock all the fields unless the Edit button is clicked. I didn't want to use the onload event on the form because then it will only apply when it loads the form. I used the following code for the Forms AfterUpdate Event: Private Sub Form_AfterUpdate() Dim c As Control On Error Resume Next For Each c In Me.Controls c.Locked = True Next End Sub and the following for the Edit Button Click Event: Private Sub Edit_Record_Click() Dim c As Control On Error Resume Next For Each c In Me.Controls c.Locked = False Next End Sub The problem I'm having is that when I first open the form and add a new record, then click the add new record button I can't just start typing, I first have to click on the edit button and then start typing into the fileds. Is there a way to fix that? Also, if I click on the edit button and I don't edit the record then click the next button, it doesn't end the command until I change a record. |
#6
|
|||
|
|||
Locking Fields
Well that solves the locking fileds but the following is still happening.
The problem I'm having is that when I first open the form and add a new record, then click the next button to add another new record I can't just start typing again, I have to click on the edit command button and then start typing into the fields. Is there a way to fix that? Also, if I click on the edit command button and I don't edit the record, then click the next button, it doesn't end the command until I change a record. Thanks. "Allen Browne" wrote: Put the statement into the On Load property. If you want to use a line in the event procedure instead, it would be: Call LockBoundControls(Me, True) If you used a command button (not a toggle button), it should be possible to click it even if the form's AllowEdits property is No. -- 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. "Mya48" wrote in message ... If I set the AllowEdits property to No, my edit button doesn't work at all. I followed step by step the instructions from the web page you suggested and I'm getting a compile error saying: Expected: Line number or label or statement or end of statement It's giving me the error on this statement Private Sub Form_Load() =LockBoundControls([Form],True) End Sub Thanks. "Allen Browne" wrote: Could you get away with just setting the form's AllowEdits property to No, while leaving AddAdditions as Yes? That may not be enough if you have unbound controls you want to edit, subforms that need to be set too, or selected controls that should not be unlocked. For those cases, see: Locking bound controls on a form and subforms. at: http://allenbrowne.com/ser-56.html "Mya48" wrote in message ... I have a form which I want to lock all the fields unless the Edit button is clicked. I didn't want to use the onload event on the form because then it will only apply when it loads the form. I used the following code for the Forms AfterUpdate Event: Private Sub Form_AfterUpdate() Dim c As Control On Error Resume Next For Each c In Me.Controls c.Locked = True Next End Sub and the following for the Edit Button Click Event: Private Sub Edit_Record_Click() Dim c As Control On Error Resume Next For Each c In Me.Controls c.Locked = False Next End Sub The problem I'm having is that when I first open the form and add a new record, then click the add new record button I can't just start typing, I first have to click on the edit button and then start typing into the fileds. Is there a way to fix that? Also, if I click on the edit button and I don't edit the record then click the next button, it doesn't end the command until I change a record. |
#7
|
|||
|
|||
Locking Fields
Use the form's Current event.
-- 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. "Mya48" wrote in message ... Well that solves the locking fileds but the following is still happening. The problem I'm having is that when I first open the form and add a new record, then click the next button to add another new record I can't just start typing again, I have to click on the edit command button and then start typing into the fields. Is there a way to fix that? Also, if I click on the edit command button and I don't edit the record, then click the next button, it doesn't end the command until I change a record. Thanks. |
#8
|
|||
|
|||
Locking Fields
Can anyone help? I've got everything else working except when I am entering
records. I can enter one because the form opens up on a new record but when I click the next record button I can't start typing in a field without having to click on the edit button. I've used the code below. This is driving me crazy. Thanks. "Ian King" wrote: You could try me.allowedits = me.newrecord on the load event. Your edit button will then be me.allowedits = true. Ian King "Mya48" wrote in message ... I have a form which I want to lock all the fields unless the Edit button is clicked. I didn't want to use the onload event on the form because then it will only apply when it loads the form. I used the following code for the Forms AfterUpdate Event: Private Sub Form_AfterUpdate() Dim c As Control On Error Resume Next For Each c In Me.Controls c.Locked = True Next End Sub and the following for the Edit Button Click Event: Private Sub Edit_Record_Click() Dim c As Control On Error Resume Next For Each c In Me.Controls c.Locked = False Next End Sub The problem I'm having is that when I first open the form and add a new record, then click the add new record button I can't just start typing, I first have to click on the edit button and then start typing into the fileds. Is there a way to fix that? Also, if I click on the edit button and I don't edit the record then click the next button, it doesn't end the command until I change a record. Thank you. |
#9
|
|||
|
|||
Locking Fields
Did you try the form's Current event?
-- 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. "Mya48" wrote in message ... Can anyone help? I've got everything else working except when I am entering records. I can enter one because the form opens up on a new record but when I click the next record button I can't start typing in a field without having to click on the edit button. I've used the code below. This is driving me crazy. |
#10
|
|||
|
|||
Locking Fields
I did and it is still not working for me.
"Allen Browne" wrote: Did you try the form's Current event? -- 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. "Mya48" wrote in message ... Can anyone help? I've got everything else working except when I am entering records. I can enter one because the form opens up on a new record but when I click the next record button I can't start typing in a field without having to click on the edit button. I've used the code below. This is driving me crazy. |
|
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Updating fields and links before printing ... | Sharon M. | General Discussion | 6 | May 7th, 2006 11:58 PM |
enable a field if a given field is checked off- otherwise- don't w | babs | Using Forms | 9 | April 18th, 2006 03:36 PM |
Invisible Multiple Fields in PageHeaders (Word 2003) | Roberto Villa Real | Mailmerge | 4 | September 24th, 2005 10:53 PM |
Word XE fields should be toggled fields, not Hidden Text. | Monty | Page Layout | 1 | September 16th, 2005 09:54 PM |
improving performance by indexing query criteria fields | Paul James | Running & Setting Up Queries | 20 | February 16th, 2005 07:55 PM |