programmatically lock controls?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • steph

    #1

    programmatically lock controls?

    Hi,

    I'm using Access 2002 and this is my question:

    I've got a form in datasheet view containing a checkbox. I want to
    lock/unlock this checkbox programmaticall y dependent on the value of a
    another control. I've tried it like this, but the checkbox does not
    seem to be set always correctly:

    Private Sub Form_Current()
    If Me.BATCHVALFROZ EN = -1 Or IsNull(Me.EXP_T YPE) Then
    Me.BATCHVAL.Loc ked = True
    Else
    Me.BATCHVAL.Loc ked = False
    End If
    End Sub

    Is there a better way to do this?

    Thanks,
    Stephan

  • Allen Browne

    #2
    Re: programmaticall y lock controls?

    That looks correct, but you need to do it in Form_AfterUpdat e as well if you
    want it locked without having to move to another record and back.

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "steph" <stephan0h@yaho o.dewrote in message
    news:1152265328 .406884.29630@7 5g2000cwc.googl egroups.com...
    >
    I'm using Access 2002 and this is my question:
    >
    I've got a form in datasheet view containing a checkbox. I want to
    lock/unlock this checkbox programmaticall y dependent on the value of a
    another control. I've tried it like this, but the checkbox does not
    seem to be set always correctly:
    >
    Private Sub Form_Current()
    If Me.BATCHVALFROZ EN = -1 Or IsNull(Me.EXP_T YPE) Then
    Me.BATCHVAL.Loc ked = True
    Else
    Me.BATCHVAL.Loc ked = False
    End If
    End Sub
    >
    Is there a better way to do this?
    >
    Thanks,
    Stephan

    Comment

    • steph

      #3
      Re: programmaticall y lock controls?

      Thanks, it works now!

      Allen Browne wrote:
      That looks correct, but you need to do it in Form_AfterUpdat e as well if you
      want it locked without having to move to another record and back.
      >
      --
      Allen Browne - Microsoft MVP. Perth, Western Australia.
      Tips for Access users - http://allenbrowne.com/tips.html
      Reply to group, rather than allenbrowne at mvps dot org.
      >
      "steph" <stephan0h@yaho o.dewrote in message
      news:1152265328 .406884.29630@7 5g2000cwc.googl egroups.com...

      I'm using Access 2002 and this is my question:

      I've got a form in datasheet view containing a checkbox. I want to
      lock/unlock this checkbox programmaticall y dependent on the value of a
      another control. I've tried it like this, but the checkbox does not
      seem to be set always correctly:

      Private Sub Form_Current()
      If Me.BATCHVALFROZ EN = -1 Or IsNull(Me.EXP_T YPE) Then
      Me.BATCHVAL.Loc ked = True
      Else
      Me.BATCHVAL.Loc ked = False
      End If
      End Sub

      Is there a better way to do this?

      Thanks,
      Stephan

      Comment

      Working...