clear listbox when record refresh

alvincgp

New member
Local time
Today, 10:32
Joined
Aug 1, 2013
Messages
9
I have a listbox in a form that is NOT bound to any table and how can I delete the listbox when I refresh my record?
 
to blank the listbox:

me.list0=""

to delete each element:

for i = me.list0.listcount-1 to 0 step -1
me.list0.removeitem(i)
next
 
Just to clarify, which of the following do you mean
1. clear the selection(s) made
or
2. delete the contents of the listbox

What type of listbox - single or multiselect? Is the row source a value list?
 
in this form, I have a vba for selecting files outside access as attachment in outlook. the files selected will be input in the listbox.

I do not need the files to be recorded in the access, so whenever a user click for next or new record the listbox shall be cleared.

the listbox is a value list.
 
hi arnelgp,

my refresh button is built with embedded macro on the On Click event.

is there anywhere I can code the vba the listbox event?
 
create a public function in a Module
Code:
public function fnClearList(Byref lst As Listbox)
Dim i as integer
for i = lst.listcount-1 to 0 step -1
lst.removeitem(i)
next
end function
on the embedded macro Runcode your pulic function:
Code:
fnClearList([listboxNameOnTheForm])
 
you're welcome.
 

Users who are viewing this thread

Back
Top Bottom