Experts:
I need some assistance with throwing a message box depending on whether or not a listbox has a value. My listbox resides on a tab control (Page Index = 3).
Background:
- Form name: F124_N1S_Billet
- Page/tab control name: tabBillet
- Page/tab index number: 3
- Listbox name: lstCFT_Summary
Process:
- Upon opening form "F124_N1S_Billet", I want to throw a message indicating either "Listbox is empty!" or "Assigned to WQSB!".
- The "Assigned to WQSB" message box shown be thrown when there's at least one (1) value shown in the listbox (for current record).
- Naturally, it needs to check the listbox value based on the current record. So, once I navigate from one record to the next, I want the IF to check again and throw the message box.
- Please do keep in mind that throwing the message box is for testing my code only. Once it is properly activated, I will replace the message box with a different action (i.e., enabling/disabling another control).
Current VBA:
- As of right now, I use the VBA below.
- Unfortunately, at this time I always get the message box from the Else statement ("Assigned to WQSB") even if the listbox is empty.
My question: How do I need to modify the IF statement (i.e., using a correct form/tab/page/listbox reference) so that the If/Else is properly checked?Code:Private Sub Form_Current() 'If Forms![F124_N1S_Billet]![tabBillet]![lstCFT_Summary].ItemData(0) = "" Then If Forms![tabBillet]![lstCFT_Summary].ItemData(0) = "" Then MsgBox "Listbox is empty!" Else MsgBox "Assigned to WQSB!" End If End Sub
Thank you,
EEH