Set control property in subroutine

  • Thread starter Thread starter Rob
  • Start date Start date
R

Rob

I would like a common subroutine to check for a value in
one control and then lock or unlock another control. My
approach, which didn't work, was to pass the control as a
parameter:

Private Sub AddCPT_GotFocus()
CheckROP AddCPT
End Sub

Private Sub CheckROP(pObject As Control)

If IsNull(Decision.Value)Then
pObject.Value = Null
pObject.Locked = True
Else
pObject.Locked = False
End If

End Sub

This Access 2K code is my ideal state. Is there a fix to
what I have attempted or another way to do it?

TIA,

Rob
 
Good grief! This syntax does work. I just needed to pay
attention to the message I was getting. AddCPT is a
checkbox. The problem was that I was trying to set it to
Null (and TripleState was set to No) - not that there was
anything wrong with my passing the object as a parameter.
When I set it to False (rather than No), everything worked.

TIA to anyone who read the message with the intention of
reponding,

Rob
 
Rob said:
I would like a common subroutine to check for a value in
one control and then lock or unlock another control. My
approach, which didn't work, was to pass the control as a
parameter:

Private Sub AddCPT_GotFocus()
CheckROP AddCPT
End Sub

Private Sub CheckROP(pObject As Control)

If IsNull(Decision.Value)Then
pObject.Value = Null
pObject.Locked = True
Else
pObject.Locked = False
End If

End Sub

Rob,

I guess you cannot lock a control having the focus. Please give some
more details as to when, under what conditions do you want this
happen?

Best regards
Emilia

Emilia Maxim
PC-SoftwareService, Stuttgart
http://www.maxim-software-service.de
 
Back
Top