Uncheck Items in ListBox.

P

Prohock

I have a list box called "ListPrint". The Control is "PrintValue" (from the
table TbPrintValue) the Rowsource is "TbPrintForm" (Table that has all the
list box items) and the form's record source is "TbPintValue". I have the
following code to reset the form so that the check boxes in the list box can
be checked again. Unfortunately it does not work and the items checked
remained checked. Please help.

Private Sub Form_Close()
Dim varItem As Variant

For Each varItem In Me!ListPrint.ItemsSelected
Me!ListPrint.Selected(varItem) = False
Next varItem
End Sub
 
T

Tom Wickerath

Hi "Prohock",

The code you indicated should give you a compile error when/if you attempt
to compile your code (Debug | Compile {ProjectName} ), where {ProjectName} is
the name of your VBA Project. The reason is that .ItemsSelected requires
arguments that are not optional. Try this instead:

For Each varItem In Me!ListPrint.ListCount - 1


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________
 
P

Pendragon

I use the following in a command button on a form to clear all selections.
Essentially the same as what you have except the With/End With. If this
doesn't work, as always, double check control names, etc.

With Me.lstGroup
For Each varSelected In .ItemsSelected
.Selected(varSelected) = False
Next
End With
 
P

Prohock

Thank you for your help!

I added the original code that I posted to a button (On CLick) and it
worked. I had it originally located (On Close). I don't know why it does not
work when you click the access close button for the form and it does work on
the close button I created?
 

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

Similar Threads


Top