In my case, I have a form with a subform. The subform was populated by a
query. User should be able to view and enter new records but should not be
able to edit existing records. Each record has several fields; the important
one is [Rate] and [Type]. If data is entered in [Rate] and [Type] then that
record or these two fields should be locked for editing.
I tried to do something like this…
I did this by adding VB code to the LostFocus() event of [Type] field.
Private Sub Charge_Type_LostFocus()
If Not IsNull(Me.Rate) and Not isNull(me.Type) Then
Me.Rate.Enabled = False
Me.Type.Enabled = False
End If
End Sub
As you can expect, this will lock all the record in the list including the
ability to enter new records from the bottom of the list. Id there any
relatively simple way to handle this?
That's what else is for, and I'd use it in the form's Current event:
Private Sub Form_Current()
If Not IsNull(Me.Rate) and Not IsNull(Me.Type) Then
Me.Rate.Enabled = False
Me.Type.Enabled = False
Else
Me.Rate.Enabled = True
Me.Type.Enabled = True
End If
End Sub

Signature
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
> In my case, I have a form with a subform. The subform was populated by a
> query. User should be able to view and enter new records but should not be
[quoted text clipped - 17 lines]
> ability to enter new records from the bottom of the list. Id there any
> relatively simple way to handle this?
Silvio - 27 May 2008 01:30 GMT
Arvin thank you for you response, however still dosent work. All the records
are locked and when I try to add a new record I can not click on the Rate
field in order to start to create a new record. When a click on a different
filed of the same raw then all the records are unlocked even though the
re-lock if I try to make modifications. Any idea?
> That's what else is for, and I'd use it in the form's Current event:
>
[quoted text clipped - 28 lines]
> > ability to enter new records from the bottom of the list. Id there any
> > relatively simple way to handle this?
Arvin Meyer [MVP] - 27 May 2008 13:01 GMT
I may not have understood. To lock existing records, you can adjust the
form's property sheet.
On the property sheet data tab turn off Allow Editing and Allow Deletions,
and leave Allow Additions on. No code at all. Existing records cannot be
edited or deleted, and new ones can be added.

Signature
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
> Arvin thank you for you response, however still dosent work. All the
> records
[quoted text clipped - 39 lines]
>> > ability to enter new records from the bottom of the list. Id there any
>> > relatively simple way to handle this?
Jan Baird - 27 May 2008 20:52 GMT
Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.