Solved Macro to Clear Listbox (1 Viewer)

justin0312

New member
Local time
Today, 12:04
Joined
Jul 2, 2021
Messages
9
I have a macro to clear my forms (cbo, txtbox). Recently, I added few listbox to my form and the clear button wont work. Anyone can advise?

My current macro is using runmenucommand > UndoRecord
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:04
Joined
Oct 29, 2018
Messages
15,541
Try assigning the null value to your listbox.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 23:04
Joined
Feb 28, 2001
Messages
20,224
Do the added listboxes have default selections defined? An UNDO would take effect but if there is a default, it would be re-asserted.
 

arnelgp

once i caught a fish alive...
Local time
Today, 12:04
Joined
May 7, 2009
Messages
13,192
On macro Designer, make sure that you toggle "Show All Actions"

Add to your macro:

SetValue
Item: [listboxnameHere]
Expression: [listboxnameHere].[ItemData](0)

SetValue
Item: [listboxnameHere]
Expression: -1
 

justin0312

New member
Local time
Today, 12:04
Joined
Jul 2, 2021
Messages
9
On macro Designer, make sure that you toggle "Show All Actions"

Add to your macro:

SetValue
Item: [listboxnameHere]
Expression: [listboxnameHere].[ItemData](0)

SetValue
Item: [listboxnameHere]
Expression: -1
I tried and is not working. Maybe i do it wrongly. Do you have any image example?
 

arnelgp

once i caught a fish alive...
Local time
Today, 12:04
Joined
May 7, 2009
Messages
13,192
test and check
 

Attachments

  • clearListboxSample.accdb
    496 KB · Views: 6

Users who are viewing this thread

Top Bottom