lock a control on a form

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
 
J

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
.
 
S

Sandra Daigle

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top