Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2004
    Posts
    173

    Unanswered: Show/Hide Datasheet Columns Programatically

    I have a form with a subform on it that is a datasheet.
    There is a column in the datasheet named Category.

    I would like a checkbox on the main form to allow the user to show or hide the Category column.

    I tried the code below and could not get it to work.

    Is there a way to show or hide the datasheet columns based on the value of a checkbox?


    I could change the source object to show another subform, but would rather have only one subform vs several.


    Thanks - AB


    Private Sub Check143_AfterUpdate()
    If Me.Check143 = True Then

    frmStockDS.Form.Category.Visible = True
    ElseIf Me.Check143 = False Then
    frmStockDS.Form.[Stock No.].SetFocus ' take focus off Category
    frmStockDS.Form.Category.Visible = False

    End If

    End Sub

    ' I also tried


    Private Sub Check143_AfterUpdate()
    If Me.Check143 = True Then

    frmStockDS.Form.Category.Column.Show
    ElseIf Me.Check143 = False Then
    frmStockDS.Form.[Stock No.].SetFocus ' take focus off Category
    frmStockDS.Form.Category.Column.Hide

    End If

    End Sub

  2. #2
    Join Date
    Feb 2004
    Posts
    137
    Try:
    Code:
    Private Sub Check143_AfterUpdate()
    If Me.Check143 = True Then
    
    frmStockDS.Form.Category.ColumnHidden = False
    ElseIf Me.Check143 = False Then
    frmStockDS.Form.[Stock No.].SetFocus ' take focus off Category
    frmStockDS.Form.Category.ColumnHidden = True
    
    End If
    
    End Sub
    See if this works for you.

  3. #3
    Join Date
    Aug 2004
    Posts
    173

    Thank You! - Works Perfectly!!!!!

    Thanks Matthew:

    Works Perfectly!

    AB


    Quote Originally Posted by Matthew Reeves
    Try:
    Code:
    Private Sub Check143_AfterUpdate()
    If Me.Check143 = True Then
    
    frmStockDS.Form.Category.ColumnHidden = False
    ElseIf Me.Check143 = False Then
    frmStockDS.Form.[Stock No.].SetFocus ' take focus off Category
    frmStockDS.Form.Category.ColumnHidden = True
    
    End If
    
    End Sub
    See if this works for you.

Posting Permissions

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