Solved Macro to Clear Listbox (1 Viewer)

justin0312

New member
Local time
Tomorrow, 01:26
Joined
Jul 2, 2021
Messages
22
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
Today, 10:26
Joined
Oct 29, 2018
Messages
21,358
Try assigning the null value to your listbox.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 12:26
Joined
Feb 28, 2001
Messages
26,999
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

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:26
Joined
May 7, 2009
Messages
19,169
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
Tomorrow, 01:26
Joined
Jul 2, 2021
Messages
22
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

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:26
Joined
May 7, 2009
Messages
19,169
test and check
 

Attachments

  • clearListboxSample.accdb
    496 KB · Views: 211

Users who are viewing this thread

Top Bottom