Forum

Userform Activate L...
 
Notifications
Clear all

Userform Activate List VBA

4 Posts
2 Users
0 Reactions
74 Views
(@stevenbehr1)
Posts: 92
Estimable Member
Topic starter
 

Hi,

 

I have created a warehouse module that I am completing and have 22 listboxes that consist of 22 lines to click on

With this in Mind, I have created a Userform Activate that whenever an order has been raised a 'Check Order" userform and VBA code below selects all 22 listboxes and populates into various 22 lines in the text boxes.

However, if there is no data part lstlookup, it indicates Run-time error 380, could not set the selected property. Invalid property value.

 

is there a VBA coding that if there was no Data or Value in any listbox to continue with the opening of the userform.

Private Sub Userform_Activate()

'Dim arrItems() As String

Dim bRB As MSForms.ReturnBoolean

lstLookup.Selected(0) = True

lstLookup_DblClick bRB

lstLookup1.Selected(0) = True

lstLookup1_DblClick bRB

I have put a "Comma" in front of lstLookup1 to verify if there was no data in this listbox and sure enough debug indicates lstLookup2

'lstlookup1.Selected(0) = True

'lstlookup1_DblClick bRB

 

Thanks

 

Steve

 
Posted : 30/01/2020 9:52 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Steve,

Please supply your workbook and code.  Too hard to debug without them.

regards

Phil

 
Posted : 31/01/2020 12:03 am
(@stevenbehr1)
Posts: 92
Estimable Member
Topic starter
 

Thanks Phil,

 

When you open

Password:Betty

Passcode:1111

Hit ALT+F11

 

Under form - frmCreatePickTicket2 --RUN

It will then debug

Userform relates to TAB(Sheet12) CheckOrder. There is no data from ID 7 to 22

need to automatically after running  frmorder userform to completion run Checkorder.

 

Thanks

 
Posted : 31/01/2020 12:32 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Steve,

If there's nothing in the list you'll get this error.  To check if there's nothing in the list you'll need to do something like 

   If lstLookup6.ListCount = 0 Then

      'List is empty

   Else

      'List has items

   End if

But, why use ListBoxes?  Why not just use Text Boxes and avoid this hassle?

Regards

Phil

 
Posted : 31/01/2020 7:12 am
Share: