Listbox after update event VBA Đầy đủ

Listbox after update event VBA Đầy đủ

Kinh Nghiệm Hướng dẫn Listbox after update sự kiện VBA Mới Nhất


You đang tìm kiếm từ khóa Listbox after update sự kiện VBA được Cập Nhật vào lúc : 2022-12-18 07:42:07 . Với phương châm chia sẻ Thủ Thuật về trong nội dung bài viết một cách Chi Tiết 2022. Nếu sau khi tìm hiểu thêm tài liệu vẫn ko hiểu thì hoàn toàn có thể lại phản hồi ở cuối bài để Mình lý giải và hướng dẫn lại nha.


Here’s something new I just learned from a recent forum discussion: A Listbox’s AfterUpdate sự kiện will fire when VBA is used to select an item on the list using the Form’s OnLoad sự kiện. What? Did you all know that? I wasn’t aware of it until now.


Typically, the AfterUpdate sự kiện of a control does not fire when the value of that control was updated using code. If you want the code behind the AfterUpdate sự kiện to execute when you update a control using VBA, you will have to specifically call it. For example:


Call ListboxName_AfterUpdate
However, as I was saying, there is a specific scenario (I know of only one, so far) where a Listbox’s AfterUpdate sự kiện will fire, without specifically calling it, when the Listbox is manipulated using VBA code. Here’s the giảm giá…


As demonstrated in this forum discussion, the OP used the Selected property to “highlight” an item in a Listbox during the Form’s Load sự kiện. Interestingly enough, this causes the form to fire the Listbox’s AfterUpdate sự kiện as well. Typically, using the Selected property does not update the value of a Listbox, which means the AfterUpdate sự kiện shouldn’t fire. But for some reason, this is not the case during the Form’s Load sự kiện. It turns out, setting the Selected property of an item in a Listbox during the Form’s Load sự kiện also updates the Listbox’s Value property. However, there is a twist… If we used the “normal” way of updating the Value of the Listbox, then the AfterUpdate sự kiện does not fire. To clarify, we can use any of the following methods to change the Value of the Listbox.


Me.ListboxName = “SomeValue” ‘if it’s bound to a Text column

Me.ListboxName = 1 ‘if it’s bound to an ID column

Me.ListboxName = Me.ListboxName.ItemData(2)
So, the puzzle is, what is going on here? Why does it happen when we use the Selected property? Also, why does it only happen during the Form’s Load sự kiện? Once the Form is fully opened, using the Seleted property merely highlights the item. It does not update its Value, and the AfterUpdate sự kiện does not fire. Equally, using any of the methods shown above to modify the Value of the Listbox this point also does not fire the AfterUpdate sự kiện.


If you have any ideas or logical explanation for this, I would really like to hear it. If I find out the answer somewhere else, I will definitely let you know.


Thank you for reading!



Reply

0

0

Chia sẻ


Chia Sẻ Link Cập nhật Listbox after update sự kiện VBA miễn phí


Bạn vừa tìm hiểu thêm Post Với Một số hướng dẫn một cách rõ ràng hơn về Review Listbox after update sự kiện VBA tiên tiến và phát triển nhất Chia Sẻ Link Cập nhật Listbox after update sự kiện VBA Free.



Hỏi đáp vướng mắc về Listbox after update sự kiện VBA


Nếu sau khi đọc nội dung bài viết Listbox after update sự kiện VBA vẫn chưa hiểu thì hoàn toàn có thể lại phản hồi ở cuối bài để Mình lý giải và hướng dẫn lại nha

#Listbox #update #sự kiện #VBA

Related posts:

Post a Comment

Previous Post Next Post

Discuss

×Close