Refresh v. Requery

E

el zorro

I have a List Box on a form that I want to be refreshed
or requeried when the user clicks a check box. Basically,
there's a list of records. The user selects a record from
the list Box. Information from the record is displayed on
the form for that record. The user check a check box
field for that record. Then the record is supposed to be
taken off the list.

I have tried two approaches inthe Afeter Update event for
the check box. One works, and the other doesnt:

Dim ctList As ListBox

'Add or remove app't from list based on checkbox
'This Requery doesn't work. Why?
'Set ctList = Me!List6
'ctList.Requery

'Refresh-- This works
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, ,
acMenuVer70

I can't get the requery method to work (it's commented
out now), but the DoCmd refresh code DOES work.

So, I have 2 questions. (1) Why doesn't the Requery
method (which is now commented out) work? (2) If I could
get it to work, which code would be preferable-- to
requery the list or do the refresh?
 
D

Dirk Goldgar

el zorro said:
I have a List Box on a form that I want to be refreshed
or requeried when the user clicks a check box. Basically,
there's a list of records. The user selects a record from
the list Box. Information from the record is displayed on
the form for that record. The user check a check box
field for that record. Then the record is supposed to be
taken off the list.

I have tried two approaches inthe Afeter Update event for
the check box. One works, and the other doesnt:

Dim ctList As ListBox

'Add or remove app't from list based on checkbox
'This Requery doesn't work. Why?
'Set ctList = Me!List6
'ctList.Requery

'Refresh-- This works
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, ,
acMenuVer70

I can't get the requery method to work (it's commented
out now), but the DoCmd refresh code DOES work.

So, I have 2 questions. (1) Why doesn't the Requery
method (which is now commented out) work? (2) If I could
get it to work, which code would be preferable-- to
requery the list or do the refresh?

Probably you need to save the current record, including the value of the
field the check box is bound to, before you requery the list box. Try

If Me.Dirty Then Me.Dirty = False
Me!List6.Requery
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top