I want to read a record into a UserForm (to update the record) - I have this working fine in one Workbook as follows ...
But in a new Workbook the following fails on the last line (Run-time error '380': Could not set the Value property. Invalid property value.) ...
... even though the MsgBox returns the correct value!
Any ideas?
Many thanks ...
VBA Code:
Private Sub UserForm_Initialize()
'Populate all ComboBoxes with dropdowm lists (from "Look Up Tables")
With Sheets("Look Up Tables")
Me.cboStrategyAlignment.List = .Range("B2", .Cells(.Rows.Count, "B").End(xlUp)).value
Me.cboDepartment.List = .Range("C2", .Cells(.Rows.Count, "C").End(xlUp)).value
Me.cboStatus.List = .Range("F2", .Cells(.Rows.Count, "F").End(xlUp)).value
Me.cboImpactExisting.List = .Range("G2", .Cells(.Rows.Count, "G").End(xlUp)).value
Me.cboLikelihoodExisting.List = .Range("I2", .Cells(.Rows.Count, "I").End(xlUp)).value
Me.cboImpactAdditional.List = .Range("G2", .Cells(.Rows.Count, "G").End(xlUp)).value
Me.cboLikelihoodAdditional.List = .Range("I2", .Cells(.Rows.Count, "I").End(xlUp)).value
End With
SearchIDRow = Application.Match(SearchIDValue, Sheets("All Risks").Columns("A"), 0)
txtRiskID = Cells(SearchIDRow, 1)
txtDateAdded = Cells(SearchIDRow, 2)
cboSpokeFocus = Cells(SearchIDRow, 3)
cboStrategyAlignment = Cells(SearchIDRow, 4)
cboDepartment = Cells(SearchIDRow, 5)
Etc, etc ...
But in a new Workbook the following fails on the last line (Run-time error '380': Could not set the Value property. Invalid property value.) ...
Code:
Private Sub UserForm_Initialize()
'Populate all ComboBoxes with dropdown lists
With Sheets("Look Up Tables")
Me.cboDepartment.List = .Range("A2", .Cells(.Rows.Count, "A").End(xlUp)).value
Me.cboIncidentType.List = .Range("B2", .Cells(.Rows.Count, "B").End(xlUp)).value
Me.cboIncidentNature.List = .Range("C2", .Cells(.Rows.Count, "C").End(xlUp)).value
Me.cboIncidentFormat.List = .Range("D2", .Cells(.Rows.Count, "D").End(xlUp)).value
Me.cboDataType.List = .Range("E2", .Cells(.Rows.Count, "E").End(xlUp)).value
Me.cboInternalExternal.List = .Range("F2", .Cells(.Rows.Count, "F").End(xlUp)).value
Me.cboDataSubjectsAdvised.List = .Range("G2", .Cells(.Rows.Count, "G").End(xlUp)).value
Me.cboCausedBy.List = .Range("H2", .Cells(.Rows.Count, "H").End(xlUp)).value
Me.cboImpact.List = .Range("I2", .Cells(.Rows.Count, "I").End(xlUp)).value
Me.cboLikelihood.List = .Range("K2", .Cells(.Rows.Count, "K").End(xlUp)).value
Me.cboStatus.List = .Range("M2", .Cells(.Rows.Count, "M").End(xlUp)).value
End With
SearchIDRow = Application.Match(SearchIDValue, Sheets("Incident Log").Columns("A"), 0)
txtIncidentID = Cells(SearchIDRow, 1)
MsgBox Cells(SearchIDRow, 2)
cboStatus = Cells(SearchIDRow, 2)
Etc, etc ...
... even though the MsgBox returns the correct value!
Any ideas?
Many thanks ...