Clearing/Resettting a Dependent Combo Box

L

Legacy 425164

Guest
Hi All,

When I submit the form and am clearing the data to allow a new entry how I keep getting an error upon clearing the dependent combo box. I've Tried clearing the SubType combobox first, then RequestType, but it results in the same error. Using published code that works, it's just the reset I'm hung up on.

Code:
Private Sub RequestType_Change()
' when selecion changes, filter
' workbook range Details
' i.e. read the range to an array, then
' set RequestType.List to the array
  Dim arrFilter() As Variant
  Dim arrInp() As Variant
  Dim i As Long, j As Long
  
' put Details into an array
  With [Details]
    ReDim arrInp(.Rows.Count, 2)
    arrInp = .Value
  End With
' dimension arrFilter to the number of filtered values
  j = 1
  For i = 1 To UBound(arrInp, 1)
    If arrInp(i, 1) = RequestType.Value Then
      j = j + 1
    End If
  Next i
  ReDim arrFilter(j - 1, 2)
  
' filter the array based on RequestType value
  j = 1
  For i = 1 To UBound(arrInp, 1)
    If arrInp(i, 1) = RequestType.Value Then
      arrFilter(j, 1) = arrInp(i, 1)
      arrFilter(j, 2) = arrInp(i, 2)
      j = j + 1
    End If
  Next i
  
' reset SubType properties
  SubType.List = arrFilter()
  SubType.BoundColumn = 2
  SubType.ColumnCount = 2
  SubType.ColumnWidths = "0 cm; 2 cm"
End Sub

I am getting hung up on
Code:
ReDim arrFilter(j - 1, 2)

I am using on the cmdbutton_Submit procedure

Code:
Me.RequestType.Clear
Me.SubType.Clear

Either order doesn't work, and also used
Code:
Me.RequestType.Value = ""

Any suggestions?
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Just a note I figured it out. add
Code:
On Error Resume Next
. Probably not the most elegant way, but it works.
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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
Back
Top