Results 1 to 13 of 13
  1. #1
    3 Star Lounger
    Join Date
    Jun 2003
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Running list (VB 6)

    In Access I have a form that contains a running list of materials that I can scroll from top to bottom. There is a column for material and quantity. I want it so that I can click a button and all materials that show no quantity disapear and the ones that have a quantity >1 will be there, then when i click another button, all the materials will appear again. This list appears under section detail and is a list of text boxes

    Thanks for any help

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

    Re: Running list (VB 6)

    I am confused by "This list ... is a list of text boxes". Is this a continuous form?

  3. #3
    3 Star Lounger
    Join Date
    Jun 2003
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running list (VB 6)

    yes sorry my mistake, it is a continous form

    Thanks for helping me clarify that

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

    Re: Running list (VB 6)

    OK, you can place command buttons in the form header or footer section.

    Create a command button to hide records with Quantity = 0; we'll name it cmdHide. The OnClick code for this button looks like this:

    Private Sub cmdHide_Click()
    Me.Filter = "Quantity > 0"
    Me.FilterOn = True
    End Sub

    Create a second command button to display all records; we'll name it cmdShow. The OnClick code for this button looks like this:

    Private Sub cmdShow_Click()
    Me.Filter = ""
    Me.FilterOn = False
    End Sub

    It would also be possible to use only one button cmdToggle that hides/displays records with Quantity = 0.

    Private Sub cmdToggle_Click()
    If Me.cmdToggle.Caption = "Show All" Then
    Me.cmdToggle.Caption = "Hide Zeros"
    Me.Filter = ""
    Me.FilterOn = False
    Else
    Me.cmdToggle.Caption = "Show All"
    Me.Filter = "Quantity > 0"
    Me.FilterOn = True
    End If
    End Sub

    In all this, you must replace Quantity by the exact name of the field in your database.

  5. #5
    3 Star Lounger
    Join Date
    Jun 2003
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running list (VB 6)

    One more thing, Is it possible to create code to make all of the quantities zeros??

  6. #6
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running list (VB 6)

    Hans
    Can this same method be applied to a combo's value, ie

    Private Sub cmdHide_Click()
    Me.Filter = "combo26 ="Authorised"
    Me.FilterOn = True
    End Sub

    Sorry to intervene on some-one elses post

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

    Re: Running list (VB 6)

    You can create an update query. Start creating a query in design view based on the table (or query) that acts as record source of the form. Add the Quantity field. Select Update query from the Query menu. Enter 0 in the Update To row under Quantity. Save this query as qryClearQuantity. If you wish, you can test it in a copy of your database.

    You can put a command button on the form that executes this query. Let's say you have a command button cmdClearQuantity. The code for it would be

    Private Sub cmdClearQuantity_Click()
    DoCmd.OpenQuery "qryClearQuantity"
    End Sub

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

    Re: Running list (VB 6)

    I'll reply later - no time now - have to run <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  9. #9
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running list (VB 6)

    Thanks Hans
    I found it in the Access Help Files.

    Me.Filter = "Comments = 'Authorised'"
    Me.FilterOn = True

    Have a great weekend

  10. #10
    3 Star Lounger
    Join Date
    Jun 2003
    Posts
    238
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running list (VB 6)

    thanks to everyone <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>

  11. #11
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running list (VB 6)

    <P ID="edit" class=small>(Edited by D Willett on 14-Jun-03 08:05. )</P>Found it again.Thanks
    '=================================
    Private Sub CmbFilter_AfterUpdate()
    Me.Filter = "comments = '" & Me.CmbFilter.Column(0) & "'"
    Me.FilterOn = True
    End Sub
    '==============================================





    Hans
    As you pointed out your methods by using buttons and toggles.
    To save the numerous controls populating a form, can the filter be applied to the after update property of a combo ?

    I have 16 options where I could apply a filter, obviously this would mean 16 command buttons.
    One combo if coded correctly could dramatically save on form space.

    Would you mind supplying a little example of code for this scenario ?

  12. #12
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Running list (VB 6)

    You have it in your example CmbFilter_AfterUpdate.

    Is that the filter you mean, where Comments equal a selected item from the ComboBox?

  13. #13
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running list (VB 6)

    Yes Patt
    As you see from my example attached, I filter from one combo instead of numerous command buttons, thus reducing the number of controls needed on the form.
    It works pretty well.
    Attached Files Attached Files

Posting Permissions

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