lock a control on a form

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

I am attempting to lock a control on a form unless a user
is entering a new record, in which case I want the control
to be unlocked. I am using the following code:

Private Sub Report_Project_Change()
If Forms![Valuation].NewRecord = True Then
Me!Counterparty.Locked = False
Else
Me!Counterparty.Locked = True
End If

End Sub

When I try this, I receive an error stating that the
object doesn't support this property or method. What am I
doing wrong?

Thanks for your help,
Jason
 
Thanks, but I still receive the same error Any other
ideas.
-----Original Message-----


Jason said:
I am attempting to lock a control on a form unless a user
is entering a new record, in which case I want the control
to be unlocked. I am using the following code:

Private Sub Report_Project_Change()
If Forms![Valuation].NewRecord = True Then
Me!Counterparty.Locked = False
Else
Me!Counterparty.Locked = True
End If

End Sub

When I try this, I receive an error stating that the
object doesn't support this property or method. What am I
doing wrong?

Thanks for your help,
Jason
Try this:

If Me.NewRecord Then
Me!Counterparty.Locked = False
Else
Me!Counterparty.Locked = True
End If
.
 
Hi Jason,

What type of control is Counterparty? Is it by any chance a control on a
subform?

You might want to move this code to the Current event of the form - the
Change event fires on every keystroke into the named control so this is not
a good place to fire code to lock/unlock another control.
 
Back
Top