I have the following code and get the error ....Invalid use of Null and debug sets it on the line that starts If Len(Trim......
I believe the issue is in the line that starts With Me.Controls.....i checked this evaluation in the immediates window and it comes back null...
I have 9 combo boxes named cmbOption01 to cmbOption09...if i hard code cmbOption01 everything works fine but using the variables i get the issue...i need it to loop through all 9 to make sure not duplicated...any help would be great....i've been at this one and going in circles for hours....thanks...
[/code]
I believe the issue is in the line that starts With Me.Controls.....i checked this evaluation in the immediates window and it comes back null...
I have 9 combo boxes named cmbOption01 to cmbOption09...if i hard code cmbOption01 everything works fine but using the variables i get the issue...i need it to loop through all 9 to make sure not duplicated...any help would be great....i've been at this one and going in circles for hours....thanks...
Code:
Private Function CheckDuplicateVal(Cnt As Long) As Boolean
Dim lngTemp As Long
Dim strTemp As String
strTemp = ","
For lngTemp = 1 To Cnt
With Me.Controls("cmbOption" & Format(lngTemp, "00"))
If Len(Trim$(.Value)) > 0 Then
If InStr(strTemp, UCase$(.Value) & ",") > 0 Then
MsgBox "Duplicate Value: " & .Value, vbInformation
CheckDuplicateVal = False
Exit Function
Else
strTemp = strTemp & UCase$(.Value) & ","
End If
End If
End With
Next lngTemp
CheckDuplicateVal = True
End Function 'CheckDuplicateVal