PDA

View Full Version : Solved: could not set the value property. Invalid property value



scott56
07-23-2010, 01:47 PM
Hi,

I have a userform I am modifying and I have placed a new combo box on it. Using a standard approach to populate it and then I want to set the value of the box to read "Select Existing Record..." when I hit this statement it reports "Could not set the value property. Invalid property value"

I have the style set to "0 - fmStyleDropCombo" which on reading other posts should allow the Combo value to be set to anything that is not in the list.....for some reason this seems to be overridden...

When I change the line .frmExistingRecordsComboBox.Value = "Select Existing Record..." to be equal to a value in the first column of the combo box it passes this line and sets the form with the combo box equal to that item in the list.....

Sub PopulateExistingRecordsComboBox()
'This routine will populate the Existing Records Combo Box
Dim myRange As Range
Dim i As Integer
With AD_DataEntry

.frmExistingRecordsComboBox.Clear

Set myRange = Worksheets("Data").Range("DataStartHeading")
i = 1
Do While myRange.Offset(i, 0).Value <> ""
With .frmExistingRecordsComboBox
.AddItem myRange.Offset(i, 0).Value
.List(.ListCount - 1, 1) = myRange.Offset(i, 4).Value
.List(.ListCount - 1, 2) = myRange.Offset(i, 1).Value
End With
i = i + 1
Loop
.frmExistingRecordsComboBox.Value = "Select Existing Record..."
End With
End Sub

Any help appreciated...

Bob Phillips
07-23-2010, 04:09 PM
You have to add that as an item to the combo.

scott56
07-23-2010, 05:29 PM
Ok.....some more investigation found the following

For the 1st column of the combo box I had a value of 0 length. This then required that any value entered would match that value. If I set the length to anything longer than 0 then the column appeared and I could set the value of the combo box to whatever value was required...