Enabling and Disabling Fields in Access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Timas
    New Member
    • Jul 2007
    • 2

    #1

    Enabling and Disabling Fields in Access

    Hi

    I'm a bit of a newbie on Access. I'm using Access 2000 and am trying to disable some fields on a form based on the values selected in other fields on the same form.

    I'm using the AfterUpdate function on the fields to enable / disable the fields:

    -------------------
    [Code=vb]Private Sub field1_AfterUpd ate()
    If field1.Value = "Partial" Then
    txtdoc.Enabled = False
    ElseIf field1.Value = "Full" Then
    txtdoc.Enabled = True
    Else
    txtdoc.Enabled = False
    End If
    End Sub
    [/Code]
    ----------------

    This works while I am in the record being updated however when I move to the previous / next record the enabled / disabled fields remain acording to the last updated one. Is there a function that I can use to check the data in the previous / next record and enable / disable fields accordingly?

    Any help would be much appreciated!
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Originally posted by Timas
    Hi

    I'm a bit of a newbie on Access. I'm using Access 2000 and am trying to disable some fields on a form based on the values selected in other fields on the same form.

    I'm using the AfterUpdate function on the fields to enable / disable the fields:

    -------------------
    [Code=vb]Private Sub field1_AfterUpd ate()
    If field1.Value = "Partial" Then
    txtdoc.Enabled = False
    ElseIf field1.Value = "Full" Then
    txtdoc.Enabled = True
    Else
    txtdoc.Enabled = False
    End If
    End Sub
    [/Code]
    ----------------

    This works while I am in the record being updated however when I move to the previous / next record the enabled / disabled fields remain acording to the last updated one. Is there a function that I can use to check the data in the previous / next record and enable / disable fields accordingly?

    Any help would be much appreciated!
    Please use the Code Tags.

    You have to put a copy of this code in the On Current event of the form.

    Also, it would be simpler for you to just do:
    [Code=vb]
    If field1.Value = "Full" Then
    txtdoc.Enabled = True
    Else
    txtdoc.Enabled = False
    End If
    [/Code]

    Comment

    • Timas
      New Member
      • Jul 2007
      • 2

      #3
      Originally posted by Rabbit
      Please use the Code Tags.

      You have to put a copy of this code in the On Current event of the form.

      Also, it would be simpler for you to just do:
      [Code=vb]
      If field1.Value = "Full" Then
      txtdoc.Enabled = True
      Else
      txtdoc.Enabled = False
      End If
      [/Code]
      That's done the trick! Thanks for this Rabbit!

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Originally posted by Timas
        That's done the trick! Thanks for this Rabbit!
        Not a problem, good luck.

        Comment

        Working...