Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

To Albert D. Kallal- Multiselect list box question

Discussion in 'Information Technology' started by serviceman via AccessMonster.com, Jul 28, 2006.

  1. serviceman via AccessMonster.com

    Guest

    Calling Dr. Kallal....
    I have been making use of your nice little multiselect form to add students
    to my attendance forms. I need to add a button to the form that will select
    ALL students. This simple code:
    Private Sub Command14_Click()

    If IsChecked(Me.STUDENT_ID) = False Then
    colCheckBox.Add CLng(Me.STUDENT_ID), CStr(Me.STUDENT_ID)
    End If
    Me.requery
    End Sub

    selects and de-selects whatever record has the focus, but I cannot get it to
    loop through all records in the form to check all students. How can I get it
    to loop? i have been farting around with this for several hours, and getting
    nowheres fast....
    Thanks again for all of your great contrbutions to this site; your insight is
    most helpful!
    andy

    --
    A $300 dollar picture tube will protect a 10 cent fuse by blowing first-
    Murphy

    Message posted via AccessMonster.com
    http://www.accessmonster.com/Uwe/Forums.aspx/access/200605/1
     
  2. Loading...


  3. Albert D.Kallal

    Albert D.Kallal
    Expand Collapse
    Guest

    Hum, if you look at the sample, when NO boxes are checked, then the report
    shows all records....

    However, in your case, I have to agree, a "select" all button would be what
    the doctor ordered...

    I would try the following button code...see if it works....

    dim rst as dao.recordset
    set rst = me.RecordSetClone

    rst.MoveFirst
    do while rst.EOF = false
    colCheckBox.Add CLng(rst!STUDENT_ID), CStr(rst!STUDENT_ID)
    rst.movenext
    loop
    set rst = nothing

    I think the above should do the trick...give it a try....


    --
    Albert D. Kallal (Access MVP)
    Edmonton, Alberta Canada
    pleaseNOOSpamKallal@msn.com
    http://www.members.shaw.ca/AlbertKallal
     
  4. serviceman via AccessMonster.com

    Guest

    Albert,
    Yes, I see that no selections return ALL records; problem was, the users
    would see a screen full of empty check boxes and go click-crazy thinking
    NOTHING was selected...

    Your code, as usual, works. I notice, however, that if the user clicks the
    button a second time (after all records have been 'checked'), then runtime
    error 457 (key already assosiated with this element) comes up. I thought i
    could avoid it by adding :

    rst.MoveFirst
    >do while rst.EOF = false

    <code added> If IsChecked(Me.STUDENT_ID) = False Then
    > colCheckBox.Add CLng(rst!STUDENT_ID), CStr(rst!STUDENT_ID)

    <code added> end if
    > rst.movenext
    >loop


    But it then only selects the first record, and the same error will come up.
    Is there a way to set this code so that if the record is checked, it ignores
    it?
    Ever-so-grateful-Andy

    Albert D.Kallal wrote:
    >Hum, if you look at the sample, when NO boxes are checked, then the report
    >shows all records....
    >
    >However, in your case, I have to agree, a "select" all button would be what
    >the doctor ordered...
    >
    >I would try the following button code...see if it works....
    >
    >dim rst as dao.recordset
    >set rst = me.RecordSetClone
    >
    >rst.MoveFirst
    >do while rst.EOF = false
    > colCheckBox.Add CLng(rst!STUDENT_ID), CStr(rst!STUDENT_ID)
    > rst.movenext
    >loop
    >set rst = nothing
    >
    >I think the above should do the trick...give it a try....
    >


    --
    A $300 dollar picture tube will protect a 10 cent fuse by blowing first-
    Murphy

    Message posted via http://www.accessmonster.com
     
  5. serviceman via AccessMonster.com

    Guest

    Albert,
    Yes, I see that no selections return ALL records; problem was, the users
    would see a screen full of empty check boxes and go click-crazy thinking
    NOTHING was selected...

    Your code, as usual, works. I notice, however, that if the user clicks the
    button a second time (after all records have been 'checked'), then runtime
    error 457 (key already assosiated with this element) comes up. I thought i
    could avoid it by adding :

    rst.MoveFirst
    >do while rst.EOF = false

    <code added> If IsChecked(Me.STUDENT_ID) = False Then
    > colCheckBox.Add CLng(rst!STUDENT_ID), CStr(rst!STUDENT_ID)

    <code added> end if
    > rst.movenext
    >loop


    But it then only selects the first record, and the same error will come up.
    Is there a way to set this code so that if the record is checked, it ignores
    it?
    Ever-so-grateful-Andy

    Albert D.Kallal wrote:
    >Hum, if you look at the sample, when NO boxes are checked, then the report
    >shows all records....
    >
    >However, in your case, I have to agree, a "select" all button would be what
    >the doctor ordered...
    >
    >I would try the following button code...see if it works....
    >
    >dim rst as dao.recordset
    >set rst = me.RecordSetClone
    >
    >rst.MoveFirst
    >do while rst.EOF = false
    > colCheckBox.Add CLng(rst!STUDENT_ID), CStr(rst!STUDENT_ID)
    > rst.movenext
    >loop
    >set rst = nothing
    >
    >I think the above should do the trick...give it a try....
    >


    --
    A $300 dollar picture tube will protect a 10 cent fuse by blowing first-
    Murphy

    Message posted via AccessMonster.com
    http://www.accessmonster.com/Uwe/Forums.aspx/access/200605/1
     
  6. serviceman via AccessMonster.com

    Guest

    Albert,
    I just noticed that the 'select all' code is only selecting those records
    that are visible in the form; If there are more records than the form can
    display without scrolling, they don't get selected...
    andy

    serviceman wrote:
    >Albert,
    >Yes, I see that no selections return ALL records; problem was, the users
    >would see a screen full of empty check boxes and go click-crazy thinking
    >NOTHING was selected...
    >
    >Your code, as usual, works. I notice, however, that if the user clicks the
    >button a second time (after all records have been 'checked'), then runtime
    >error 457 (key already assosiated with this element) comes up. I thought i
    >could avoid it by adding :
    >
    >rst.MoveFirst
    >>do while rst.EOF = false

    > <code added> If IsChecked(Me.STUDENT_ID) = False Then
    >> colCheckBox.Add CLng(rst!STUDENT_ID), CStr(rst!STUDENT_ID)

    ><code added> end if
    >> rst.movenext
    >>loop

    >
    >But it then only selects the first record, and the same error will come up.
    >Is there a way to set this code so that if the record is checked, it ignores
    >it?
    >Ever-so-grateful-Andy
    >
    >>Hum, if you look at the sample, when NO boxes are checked, then the report
    >>shows all records....

    >[quoted text clipped - 15 lines]
    >>
    >>I think the above should do the trick...give it a try....

    >


    --
    A $300 dollar picture tube will protect a 10 cent fuse by blowing first-
    Murphy

    Message posted via AccessMonster.com
    http://www.accessmonster.com/Uwe/Forums.aspx/access/200605/1
     
  7. serviceman via AccessMonster.com

    Guest

    wow...
    how odd... There is a couple second delay when scrolling, and then the boxes
    check. I guess that your code is ok (of course), but the process time is a
    bit behind..
    Andy

    serviceman wrote:
    >Albert,
    >I just noticed that the 'select all' code is only selecting those records
    >that are visible in the form; If there are more records than the form can
    >display without scrolling, they don't get selected...
    >andy
    >
    >>Albert,
    >>Yes, I see that no selections return ALL records; problem was, the users

    >[quoted text clipped - 24 lines]
    >>>
    >>>I think the above should do the trick...give it a try....

    >


    --
    A $300 dollar picture tube will protect a 10 cent fuse by blowing first-
    Murphy

    Message posted via AccessMonster.com
    http://www.accessmonster.com/Uwe/Forums.aspx/access/200605/1
     
  8. Albert D.Kallal

    Albert D.Kallal
    Expand Collapse
    Guest

    "serviceman via AccessMonster.com" <u19423@uwe> wrote in message
    news:601bbfa4865f3@uwe...

    > wow...
    > how odd... There is a couple second delay when scrolling, and then the
    > boxes
    > check. I guess that your code is ok (of course), but the process time is a
    > bit behind..


    ok....

    For the "error" problem, we can just "empty" the colleciton, so we
    don't errory out trying to add a already check box....
    *before* we start...

    So, just do

    set colCheckBox = nothing ' <--- at this to clear all

    rst.MoveFirst
    do while rst.EOF = false
    colCheckBox.Add CLng(rst!STUDENT_ID), CStr(rst!STUDENT_ID)
    rst.movenext
    loop
    set rst = nothing


    --
    Albert D. Kallal (Access MVP)
    Edmonton, Alberta Canada
    pleaseNOOSpamKallal@msn.com
    http://www.members.shaw.ca/AlbertKallal
     
  9. serviceman via AccessMonster.com

    Guest

    Albert,
    works like a charm. Thank you so much for your time and efforts....
    Andy

    Albert D.Kallal wrote:
    >> wow...
    >> how odd... There is a couple second delay when scrolling, and then the
    >> boxes
    >> check. I guess that your code is ok (of course), but the process time is a
    >> bit behind..

    >
    >ok....
    >
    >For the "error" problem, we can just "empty" the colleciton, so we
    >don't errory out trying to add a already check box....
    >*before* we start...
    >
    >So, just do
    >
    >set colCheckBox = nothing ' <--- at this to clear all
    >
    >rst.MoveFirst
    >do while rst.EOF = false
    > colCheckBox.Add CLng(rst!STUDENT_ID), CStr(rst!STUDENT_ID)
    > rst.movenext
    >loop
    >set rst = nothing
    >


    --
    A $300 dollar picture tube will protect a 10 cent fuse by blowing first-
    Murphy

    Message posted via http://www.accessmonster.com
     

Share This Page