Run time Error 380, despite the value being calculated correctly.

vbaNumpty

Board Regular
Joined
Apr 20, 2021
Messages
137
Office Version
  1. 365
Platform
  1. Windows
Encountered a weird issue today as I added editing features to my UserForm. The fourth ComboBox is giving me a property value error when I try to populate it, despite the previous three working and the VBA editor calculating the value correctly.

Untitled.png

Untitled2.png


The right side is returning a value, but the left side is giving me the invalid property. Code is as follows:
VBA Code:
Private Sub EditButton_Click()

    If Selected_List = 0 Then
        
        MsgBox "No selection.", vbOKOnly + vbInformation, "Edit"
        Exit Sub
        
    End If
    
    Dim cSelect As Variant
    Dim oSelect As Variant
    Dim uSelect As Variant
    Dim ctSelect As Variant
    Dim iSelect As Variant
    Dim sSelect As Variant
        
    'code to update the value to the respective fields
    Me.txtRowNumber.Value = Selected_List + 1
    
    Me.ProductBox.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 0)
    Me.PID.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 1)
    Me.CaseQty.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 2)
    Me.PackSizeBox.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 3)
    Me.StageBox.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 4)
    Me.AssBox.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 5)
    Me.ColourBox.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 6)
    
    cSelect = Me.ListBox1.List(Me.ListBox1.ListIndex, 7)
    If cSelect = "" Then
        Me.CoverSelect.Value = False
    Else
        Me.CoverSelect.Value = True And Me.CoverBox.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 7)
    End If
    
    oSelect = Me.ListBox1.List(Me.ListBox1.ListIndex, 8)
    If oSelect = "" Then
        Me.OrnamentSelect.Value = False
    Else
        Me.OrnamentSelect.Value = True And Me.OrnamentBox.Value = IIf(oSelect = "Yes", Me.OrnamentBox.Value = "", Me.OrnamentBox.Value = oSelect)
    End If
    
    uSelect = Me.ListBox1.List(Me.ListBox1.ListIndex, 9)
    If uSelect = "" Then
        Me.UPCSelect.Value = False
    Else
        Me.UPCSelect.Value = True And Me.UPCBox.Value = IIf(uSelect = "Yes", Me.UPCBox.Value = "", Me.UPCBox.Value = oSelect)
    End If
    
    ctSelect = Me.ListBox1.List(Me.ListBox1.ListIndex, 10)
    If ctSelect = "" Then
        Me.CareTagSelect.Value = False
    Else
        Me.CareTagSelect.Value = True
    End If
    
    iSelect = Me.ListBox1.List(Me.ListBox1.ListIndex, 11)
    If iSelect = "" Then
        Me.InsulationSelect.Value = False
    Else
        Me.InsulationSelect.Value = True
    End If
    
    sSelect = Me.ListBox1.List(Me.ListBox1.ListIndex, 12)
    If sSelect = "" Then
        Me.SleeveSelect.Value = False
    Else
        Me.SleeveSelect.Value = True
    End If
    
    Me.NotesBox.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 13)
    
    MsgBox "Please make necessary changes and click on 'Add' to save changes.", vbOKOnly + vbInformation, "Edit"

End Sub
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

diddi

Well-known Member
Joined
May 20, 2004
Messages
3,337
Office Version
  1. 2010
Platform
  1. Windows
what type of object/control is PackSizeBox
 

vbaNumpty

Board Regular
Joined
Apr 20, 2021
Messages
137
Office Version
  1. 365
Platform
  1. Windows
what type of object/control is PackSizeBox
It is a combobox, similar to other three above it CaseQty, PID, and ProductBox. I have tried to assign the value of PackSizeBox to a variant and then replace the left side of the equation with the name of the variant and I no longer get the error. The problem now is that it is the only value of the seven items listed that does not populate the combobox with the calculated value.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
37,175
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Does the value you are putting in the combobox appear in its current list of values?
 

vbaNumpty

Board Regular
Joined
Apr 20, 2021
Messages
137
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Does the value you are putting in the combobox appear in its current list of values?
When I select the drop down, the values are present yes. It may be an issue of order perhaps?
 

vbaNumpty

Board Regular
Joined
Apr 20, 2021
Messages
137
Office Version
  1. 365
Platform
  1. Windows
When I select the drop down, the values are present yes. It may be an issue of order perhaps?
Just to update, I have tried putting it as the last possible argument in the block of code and it still won't populate the combobox with the correct value.

In the code the value is now being calculated and assigned properly but the combobox refuses to populate. It's driving me mad!
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
37,175
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS

ADVERTISEMENT

Any chance you can put the file somewhere?
 

vbaNumpty

Board Regular
Joined
Apr 20, 2021
Messages
137
Office Version
  1. 365
Platform
  1. Windows
Any chance you can put the file somewhere?
Link to google drive file:


The code is on the userform under the edit button click code.

You can launch the userform and select any entry in the list box and click edit, you will see that the pack size number will not populate in the proper combobox.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
37,175
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Change the Style property of the control to fmStyeDropDownCombo and that should fix it.
 

Forum statistics

Threads
1,137,154
Messages
5,679,904
Members
419,861
Latest member
AceDaMace

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top