How to make a Listbox requery 
Author Message
 How to make a Listbox requery

Hi        ( Access 2000 running on Win2K )

I can not get a listbox to requery due to changing the state of a check box
on the form.

The scenerio

    A    On the form there is a checkbox that sets a yes/no field in the
master table to yes or no

    B    The listbox on the form has a query based on the same master table
that only displays records for which the field associated with the checkbox
are set true.

    C    I created an event for the checkbox using the On Click property.
The requery property of the list box name is called, e.g.
         myListBox.requery

The behaviour is that unless I exit the form and re-enter it, the listbox
will never show the records which have had the checkbox checked in the
session.  Requerying the entire form is slow and it seems to me that it
should be unnecessary.  Since the .requery doesn't do what I think it should
do, what is it really supposed to do then ??

I can't find anything in the KB to suggest any other way to approach this.

Seems like I'm missing something here.

    Mark



Mon, 29 Aug 2005 14:15:43 GMT  
 How to make a Listbox requery
I suspect that the problem may be that the current record, though
modified by changing the value of the check box, hasn't yet been
saved.  So if you currently have an AfterUpdate event procedure along
these lines:

    Private Sub chkMyCheckBox_AfterUpdate()
        Me.myListBox.Requery
    End Sub

you need to add a line to force the current record to be saved before
requerying.  It might then look like this:

    Private Sub chkMyCheckBox_AfterUpdate()
        Me.Dirty = False
        Me.myListBox.Requery
    End Sub

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Quote:
> Hi        ( Access 2000 running on Win2K )

> I can not get a listbox to requery due to changing the state of a
check box
> on the form.

> The scenerio

>     A    On the form there is a checkbox that sets a yes/no field in
the
> master table to yes or no

>     B    The listbox on the form has a query based on the same
master table
> that only displays records for which the field associated with the
checkbox
> are set true.

>     C    I created an event for the checkbox using the On Click
property.
> The requery property of the list box name is called, e.g.
>          myListBox.requery

> The behaviour is that unless I exit the form and re-enter it, the
listbox
> will never show the records which have had the checkbox checked in
the
> session.  Requerying the entire form is slow and it seems to me that
it
> should be unnecessary.  Since the .requery doesn't do what I think
it should
> do, what is it really supposed to do then ??

> I can't find anything in the KB to suggest any other way to approach
this.

> Seems like I'm missing something here.

>     Mark



Mon, 29 Aug 2005 14:29:59 GMT  
 How to make a Listbox requery
Yes, indeed.  That was the problem.

Your answer worked perfectly.

    Thank you

        Mark


Quote:
> I suspect that the problem may be that the current record, though
> modified by changing the value of the check box, hasn't yet been
> saved.  So if you currently have an AfterUpdate event procedure along
> these lines:

>     Private Sub chkMyCheckBox_AfterUpdate()
>         Me.myListBox.Requery
>     End Sub

> you need to add a line to force the current record to be saved before
> requerying.  It might then look like this:

>     Private Sub chkMyCheckBox_AfterUpdate()
>         Me.Dirty = False
>         Me.myListBox.Requery
>     End Sub

> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com

> (please reply to the newsgroup)



> > Hi        ( Access 2000 running on Win2K )

> > I can not get a listbox to requery due to changing the state of a
> check box
> > on the form.

> > The scenerio

> >     A    On the form there is a checkbox that sets a yes/no field in
> the
> > master table to yes or no

> >     B    The listbox on the form has a query based on the same
> master table
> > that only displays records for which the field associated with the
> checkbox
> > are set true.

> >     C    I created an event for the checkbox using the On Click
> property.
> > The requery property of the list box name is called, e.g.
> >          myListBox.requery

> > The behaviour is that unless I exit the form and re-enter it, the
> listbox
> > will never show the records which have had the checkbox checked in
> the
> > session.  Requerying the entire form is slow and it seems to me that
> it
> > should be unnecessary.  Since the .requery doesn't do what I think
> it should
> > do, what is it really supposed to do then ??

> > I can't find anything in the KB to suggest any other way to approach
> this.

> > Seems like I'm missing something here.

> >     Mark



Mon, 29 Aug 2005 15:13:56 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. .Requery does not requery listbox

2. please help with listbox.selected() values after listbox requery

3. populate listbox after another listbox selection is made

4. Making contents of listbox dependent on earlier choice in other listbox

5. Making contents of listbox dependent on earlier choice in other listbox

6. Making contents of listbox dependent on earlier choice in other listbox

7. Making contents of listbox dependent on earlier choice in other listbox

8. Requery, requery, requery

9. Making another form requery

10. Can't Requery Listbox


 
Powered by phpBB® Forum Software © phpBB Group