Results 1 to 2 of 2
  1. #1
    Lounger
    Join Date
    Oct 2001
    Location
    New York
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Enabling/Disabling fields in a Form (Access97)

    I am currently working on a form, where: If the Type of client is an "Individual" (from a dropdown list), then I want the ClientCompanyName to be disabled and the Prefix, FirstName, LastName be enabled, if the Type of Client is any other choice from the dropdown list, then the ClientCompanyName should be enabled, and the Prefix, FirstName, LastName should be disabled.

    I almost got it to work in the AfterUpdate with the following code:
    Private Sub ClientTypeID_AfterUpdate()
    If Me!ClientTypeID = 1 Then
    Me!ClientCompanyFullName.Enabled = False
    Me!ClientPrefix.Enabled = True
    Me!ClientFirstName.Enabled = True
    Me!ClientMiddleName.Enabled = True
    Me!ClientLastName.Enabled = True
    Me!ClientSuffix.Enabled = True
    Else
    Me!ClientCompanyFullName.Enabled = True
    Me!ClientPrefix.Enabled = False
    Me!ClientFirstName.Enabled = False
    Me!ClientMiddleName.Enabled = False
    Me!ClientLastName.Enabled = False
    Me!ClientSuffix.Enabled = False
    End If
    End Sub

    However, when ever I go back into the form, all of the fields are enabled again.

    Any help would be greatly appreciated.

    Thank you.
    Nadia

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Enabling/Disabling fields in a Form (Access97)

    You need the same code in your form's Current event. However, the best way to handle this is to create separate procedure (call it EnableDisableControls, or whatever) and put all the code into it. Then, just call this routine from both locations.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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