G
Guest
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.
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.