Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jan 2003
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Enabling previous record's disabled field... (Access 2000)

    I haven't had the occasion to do this in a long time and thus would appreciate help on how to solve the problem. I have the following code in a user form so that the user will not attempt to add data to both the "ProjectCode" and "OtherAllocation" fields. If there is data entered in the ProjectCode field, then the second (OtherAllocation) field becomes disabled; however, if user skips the ProjectCode field, the second (OtherAllocation) field remains enabled.

    The problem is whenever user goes to the next NEW record to enter new data, the "disabled" field from previous record stays disabled instead of both fields being enabled initially. If I close the form and reopen it, then the new record fields are okay. I'm sure that with code there is a way to refresh the new record to show both fields enabled. Any advice would be much appreciated. Many thanks...Mary

    Private Sub ProjectCode_AfterUpdate()
    If ProjectCode.Value <> "" Then
    Me!OtherAllocation.Enabled = False
    Else
    Me!OtherAllocation.Enabled = True
    End If

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Enabling previous record's disabled field... (Access 2000)

    You should use the same If ... End If code in the On Current event of the form as a whole:

    Private Sub Form_Current()
    If ProjectCode.Value <> "" Then
    Me!OtherAllocation.Enabled = False
    Else
    Me!OtherAllocation.Enabled = True
    End If
    End Sub

    or even shorter

    Private Sub Form_Current()
    Me!OtherAllocation.Enabled = IsNull(ProjectCode)
    End Sub

  3. #3
    2 Star Lounger
    Join Date
    Jan 2003
    Posts
    187
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Enabling previous record's disabled field... (Access 2000)

    Many thanks, Hans...Works like a charm! Appreciate your quick reply!...Mary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •