Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Subform Controls (A2K SR1)

    I have a Form with a Subform, each related to a different table. The Subform is used to collect line item information for a purchase order, so the Subform can contain any number of records. Depending on the value selected from a list box in Field A of the Subform, I want Field B to be enabled or disabled. Using code in the Field A AfterUpdate event, I can make that happen. Unfortunately, with my code, Field B on EVERY record of the Subform is enabled/disabled at once. Can I make this happen on INDIVIDUAL Subform records?

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform Controls (A2K SR1)

    You can't set it for individual records.
    What I do is change the enabled property in the On Current event of the subform.
    Don't forget to set the focus to another control than that you want to disable because you can't do it if it have the focus<pre>Private Sub Form_Current()
    On Error GoTo PROC_ERR
    If Me!Soort = "D" Then
    Me!Ma.Enabled = True
    Me!Ma.Locked = False
    Else
    Me![Art Nr].SetFocus
    Me!Ma.Enabled = False
    Me!Ma.Locked = True
    End If

    Exit Sub

    PROC_ERR:
    MsgBox "De volgende fout werd vastgesteld: " & Error$
    Resume Next
    End Sub
    </pre>

    Francois

  3. #3
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform Controls (A2K SR1)

    Do I set the focus to another control in the same record? Using the code you provided, when I open the Subform, all of the desired fields are disabled and stay that way regardless of my list box selection.

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform Controls (A2K SR1)

    Sorry for not mentioning, but you have to put the same code in the afterupdate of the listbox.
    To avoid having the same code twice, you can set
    Form_Current
    in the afterupdate event of the listbox.
    This will call the code in the On current event of the form.
    Francois

  5. #5
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subform Controls (A2K SR1)

    And yes, you set the focus in the same record but in another control witch will remain enabled.
    Francois

Posting Permissions

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